How to control a number of order placement?

To add comments, please log in or register
mygreensun
142
mygreensun  

Hi, 

I am building a simple EA to place an order based on MA. (i.e. when a bid price is above MA then to place a buy order....). I want to place only one order placement for each candle. Do you know how to control for this?

Best, 

Mygreen

Fabio Cavalloni
3836
Fabio Cavalloni  

If you need to open one order for each new candle you need a function to check if the new incoming tick generate a new candle or not.

// Global variables
datetime lastBar = 0;

// OnTick
   bool IsNewBar = iTime(NULL,0,0) > lastBar;
   if( IsNewBar ) {
      lastBar = iTime(NULL,0,0);
      // Code for each new bar
   }
mygreensun
142
mygreensun  

Thank you Fabio. I will try with it. 

Best regards, 

MyGreen

To add comments, please log in or register