• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 1:22am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 1:22am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

EA closing all trades and orders when profit reached? 5 replies

Closing of trades in Strategy tester does not fit to the candle 5 replies

Closing all trades when.... 13 replies

Closing all trades coding 3 replies

Closing all trades? 15 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

Code for closing all trades at new candle?

  • Post #1
  • Quote
  • First Post: Nov 18, 2008 8:10pm Nov 18, 2008 8:10pm
  •  DougNE
  • | Joined Mar 2008 | Status: Member | 6 Posts
Hi,

Does anyone have some code that works well for closing all trades at the open of a new candle? I can not seem to get it to stop, it closes all new trades as well. A comment in the code shows that CurCandle is equal to 1 for some reason. Anyway, any help appreciated.
Here is what I have come up with:

Static CurCandle=0;
//--------------------
int init()
{
CurCandle=Open[0];
return(0);
}

int deinit()
{
return(0);
}

if(Open[0] != CurCandle)
{
Cls_S=true;
Cls_B=true;
CurCandle=Open[0];
}

This is the relevant part...
  • Post #2
  • Quote
  • Nov 19, 2008 8:17am Nov 19, 2008 8:17am
  •  LongToBeFree
  • | Membership Revoked | Joined Oct 2008 | 613 Posts
It sounds like you're just looking to detect a new candle. That's better done with time

//global
datetime lastcheck;

start()
{
if(lastcheck<Time[0])
{
lastcheck=Time[0];
//do your thing
}

}
 
 
  • Post #3
  • Quote
  • Last Post: Nov 20, 2008 12:32am Nov 20, 2008 12:32am
  •  DougNE
  • | Joined Mar 2008 | Status: Member | 6 Posts
Thank You!

That is just what I needed to get this to work correctly.

I really appreciate your time and effort!
 
 
  • Platform Tech
  • /
  • Code for closing all trades at new candle?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022