OnNewBar() enough to make OHLC testing accurate ?

 

Hi !

I kindly noticed how much optimization with OHLC price was quick ! On the other hand, in real it doesn't apply. Would using OnNewBar rather than OnTick made it accurate in real condition ?

Thanks !

 

yes but if you also use fixed take profit.

for when trailing you still deal with the tick.

 
Marco vd Heijden:

yes but if you also use fixed take profit.

for when trailing you still deal with the tick.

int ExtTimeOut=14400; <-------- timeframe H4
/////////////////////////////
void OnTick(void)
  {
   static datetime limit_time=0; // last trade processing time + timeout
//--- don't process if timeout
   if(TimeCurrent()>=limit_time)
     {
      //--- check for data
      if(Bars(Symbol(),Period())>2*InpMATrendPeriod)
        {
         //--- change limit time by timeout in seconds if processed
         if(ExtExpert.Processing())
            limit_time=TimeCurrent()+ExtTimeOut;
        }
     }
  }
The results with all ticks aren't the same as OHLC even by delaying of 4h (14400s)
 
Icham Aidibe:
The results with all ticks aren't the same as OHLC even by delaying of 4h (14400s)
Since it's 1minutes OHLC, I've also tried with 60s, but no way !
 
I used OnNewBar to be able to obtain the same results using Ontick or OHLC on the tester ! This may help someone else, I didn't yet ended the optimization, but I'm already happy because every tick's optimization are very very very very ...
 

Even using Heiken Ashi based on OHLC price, seems there's no way to reproduce the results got when opt with OHLC.

BUT

There's a way to make the OHLC same as the Each tick mode, which promises a gain of time in future opt. Simply count the bars :

        int bars = Bars(_Symbol, _Period);
        // Trade only if new bar has arrived
        if (LastBars != bars) LastBars = bars;
        else return;
 

Same there. He calls it a ggrrrrrrrrrrrr -al.

https://www.mql5.com/en/code/244

Grr-al
Grr-al
  • votes: 35
  • 2011.01.05
  • Igor Volodin
  • www.mql5.com
The Expert Advisor is profitable only if the "Open prices" only or "1 minute OHLC" modes used in Strategy Tester.
 

It appears that in OHLC there's not only 4 ticks, there's less ticks than the everytick mode, but not 4. Nor Heiken Ashi, nor Renko can do it.

Even when trying to get that at your advantage :

Open ---> High : 50% (luck) then ---> Low ---> Close

Open ---> Low : 50% (luck) then ---> High ---> Close

There's less ticks, they aren't the same nor in time, nor in price value, the way is different than the everytick mode.

Reason: