Getting the Same Open Price Only Backtesting Results in Every Tick Mode

 

Hi guys,


I have backtested a strategy based of the 1 minute chart using Open Price Only Modelling.

I have then backtested the strategy using every tick mode.

To get the every tick mode to match the open price only modelling I added the following code(found in another thread):


static datetime prevFastTime; 
datetime time;
time = iTime(Symbol(), PERIOD_M1,0); 
if(time > prevFastTime) 
{ 
prevFastTime = time; 
//rest of code goes here//
}


This code correctly looks for a new bar and serves that purpose fine. However the entries are off by a few minutes and there are more entries than in the Open Price Only Modelling. Surely as both are waiting for a new bar they should match?

How is this? How do I match every tick to open price only?


Thanks for any help!

 

I have realised the above is a bit wordy so.....TLDR version: 

What code can you add to an EA script that controls the bar opening so that it performs live the same as the Open Price Only Modelling 


Thanks again.

 
  1. Your code only does that for the M1 chart.

  2. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 programming forum

 
William Roeder:
  1. Your code only does that for the M1 chart.

  2. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 programming forum

Hey,

Thank you so much for your reply.

The code you linked performed the same irregularities  i.e. - more trades and slightly different timing to Open Price Only Modelling.

Do you know why with this code, Every Tick would give different back testing results to Open Price Only when the logic is the same.  i.e. Even though the modelling is every tick , both back testing models  should only execute on the start of a new bar and so should give the same results?

Sorry if i'm missing something!

 
apinkdog: Sorry if i'm missing something!

Are you running on the M1 chart? What part of "Your code only does that for the M1 chart" was unclear?

 
William Roeder:

Are you running on the M1 chart? What part of "Your code only does that for the M1 chart" was unclear?

Yes i am running on the M1 chart. I wrote "I have backtested a strategy based of the 1 minute chart" on the second line in my first post. Maybe I should have been more clear?

What was unclear to me was how the results still differ between the two backtesting models when both (because of the bar control code) execute on the same logic and at the same time. 

Does that make sense?

Thanks again.

Reason: