How can I modify my EA for it to execute order at open price only like backtest ?

 

How can I modify my EA for it to execute order at open price only like backtest ?

 
Wait for a new bar and open.
          New candle - MQL4 programming forum #3 2014.04.04
 
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   static datetime timeCur; datetime timePre = timeCur; timeCur=Time[0];
   bool isNewBar = timeCur != timePre;
   if(isNewBar){ 
     : // Once per bar
   }
   : // every tick
  }
//+------------------------------------------------------------------+
William Roeder:
Wait for a new bar and open.
          New candle - MQL4 programming forum #3 2014.04.04

Just past like this ?

Update : it has some errors
 
Quenney Lam:

Just past like this ?

Update : it has some errors
void OnTick()
{
   static datetime barTime=0;
   datetime nowTime=iTime(_Symbol,PERIOD_CURRENT,0);
   if(barTime!=nowTime)
     {
      barTime=nowTime;
      //Here do stuff that you only want executed on a new bar open.
     }
//Here do stuff that you want executed every tick
}
 
Keith Watford:

I dont know if it work or not. Could you please accept my friend request .

My backtest is very positive so i want to make it come true lol




 
Quenney Lam:

How can I modify my EA for it to execute order at open price only like backtest ?

Interesting idea . It raises some questions : 

  1. Are the open prices treated like ticks in mt5 ? 
  2. If yes ,then you should also code custom stops and take profits to execute only in the new bar opening (yes = 1 tick = 1 open price)
  3. If not ,then you should test more to see what is processed first , the SL or the TP (no = 3 ticks = 1open 1low 1high )
  4. Same for any trailing
  5. and lastly ,why does testing with open prices only 38 days on a daily chart report a 99% history quality ?
  6. is history quality = modelling quality ?