problem in mql4 - buying on next candle (not the current) how ?

 

i am new to mql and i'm dealing with a small problem.

lets take a condition:

we have to candles: one is closed already, the second one is current still going on. (timeframe m5)

if (close_price_of_last_candle < current_price_of_current_candle)

then buy_on_begining_of_next_candle


how to implement that? how to make the system wait for the closing of current candle and then buying?

 

u can use Time[] for that

 
kristoforo:

how to implement that? how to make the system wait for the closing of current candle and then buying?

Been discussed many, many times . . . try searching . . .

if (Bar1Time != iTime(NULL, 0, 1) ) // 1st tick of new bar
   {

   // do stuff . . . 

   Bar1Time = iTime(NULL, 0, 1);
   }

I use iTime so I can use specific Periods, you can use Time[1] instead

 
kristoforo:
if (close_price_of_last_candle < current_price_of_current_candle)
then buy_on_begining_of_next_candle
int start(){
   static datetime Time0; if (Time0 == Time[0]) return(0); Time0 = Time[0];
   // wait for next candle
   // (close_price_of_last_candle < current_price_of_current_candle) wait for next candle and open.
   // Close[1] < High[0] wait for next candle
   if (Close[2] < High[1]){
      int ticket = OrderSend(...);
      if (ticket < 0) Alert(...);
   }
}