How do I force EA to process order on close?

 

Currently I am using following code to take trade on open position of new bar.

//--- go trading only for first ticks of new bar
   if(CopyRates(_Symbol,_Period,0,2,rt)!=2)
     {
      Print("CopyRates of ",_Symbol," failed, no history");
      return;
     }
   if(rt[1].tick_volume>1)
      return;

I would like to take trade on closing price of current bar. (instead of opening price of next bar)

Closing price of current candle and opening price of next candle may sound same but it gives ton of false backtesting results in "Line break chart"

Anybody here knows how to do it?

thank you in advance.


regards,

Saurabh

 
saurabhB: Currently I am using following code to take trade on open position of new bar. I would like to take trade on closing price of current bar. (instead of opening price of next bar) Closing price of current candle and opening price of next candle may sound same but it gives ton of false backtesting results in "Line break chart" Anybody here knows how to do it?

Not possible! You can only know what is the closing price of a bar, once the the opening time of a new bar comes about. And even then, there is no guarantee to open a trade with that exact price because there is always slippage and in the case of Buy order, there is also the spread to consider. The close price on the chart is a Bid price, but a Buy order will open with the Ask price.