Run Code Only on 1minOHLC price changes *Not On Every Tick* (Just Like In Strategy Tester)

 

Hi, I would like to create a function that runs through my code when 1minOHLC prices update instead of Every Tick.

I make money when I backtest on 1minOHLC modelling but not on *Real Ticks* modelling, so I would like to mimic placing trades on 1minOHLC.


example:

void OHLC 

{

   // Run code here

}


instead of:

void OnTick()

{

  // Run code here

}


I just don't know how to call my OHLC function. 

Can Anyone help?


Thanks in Advance!

 
NoodlePlexium:

Hi, I would like to create a function that runs through my code when 1minOHLC prices update instead of Every Tick.

I make money when I backtest on 1minOHLC modelling but not on *Real Ticks* modelling, so I would like to mimic placing trades on 1minOHLC.

 use 1 minute bars, check for new bar (plenty of info here how to do that) when a new bar run your function

 
NoodlePlexium:

Hi, I would like to create a function that runs through my code when 1minOHLC prices update instead of Every Tick.

I make money when I backtest on 1minOHLC modelling but not on *Real Ticks* modelling, so I would like to mimic placing trades on 1minOHLC.


example:

void OHLC 

{

   // Run code here

}


instead of:

void OnTick()

{

  // Run code here

}


I just don't know how to call my OHLC function. 

Can Anyone help?


Thanks in Advance!

You can grab the open price easily, but the high & low prices are known only at the end of the candle - the close price being the next open price ... the only possibility using that way is to trade on new bar 

 
First study how OLHC test mode deals with these "ticks" in tester https://www.mql5.com/en/articles/239 Then you will realize this method of simulation does not correlate to a real tick feed.
 
Enrique Dangeroux:
Then you will realize this method of simulation does not correlate to a real tick feed.

Are there ways of getting around this?

 
Paul Anscombe:

 use 1 minute bars, check for new bar (plenty of info here how to do that) when a new bar run your function

Unfortunately this is the same as using Open Prices, which simply doesn't work for my strategy.


Thanks for the suggestion.

 
NoodlePlexium:

Are there ways of getting around this?

No. You should only test on ticks based on real ticks. OHLC is good only for self deception or pretty pictures for market sellers.

 
I am late but I reply for those who find this thread from Google later. OHLC doesn't count the Ask/Bid spread. That's why your backtest made money. And OHLC is not realistic, using Open Price mode gives you a more accurate result but again, it doesn't count the Ask/Bid spread. 
Reason: