How To Get Closer To 1min OHLC Backtester Mode Result In Live Chart

 
So I have been watching a very interesting video series by Darwinex about improving your EA to reflect backtester results in live charts.

It seems that the best method is controlling bar opening prices. You program the EA in a way that it processes only  bar open tick so this will reflect on a live chart the backtests results when using that mode.

You can also program the EA to receive only 4 ticks (like it does on the 1min OHLC mode), but he says it also won´t quite be the same because on the tester metatrader already knows the OHLC 1min data, on the live chart obviously you can´t know that because the bar is forming.

Only after the close we get that data, but then he says it´s "too late". How 1min delay is too late? Can´t we just use the last 1min bar tick data? If you are not coding a super precise scalping EA, I don´t see what´s the problem in doing that. 

Here is the video:  https://www.youtube.com/watch?v=q8WUNHzl_RQ


Wouldn´t doing this getting us closer to the 1min OHLC mode resuts?
13) Beware! - Limitations of using '1 minute OHLC' Setting in the MT5 Strategy Tester
13) Beware! - Limitations of using '1 minute OHLC' Setting in the MT5 Strategy Tester
  • 2021.01.29
  • www.youtube.com
It's important to unify behavior between the MT5 Strategy Tester and live trading conditions. The use of '1 minute OHLC' for backtesting in the MT5 Strategy ...
 
Alberto Gauer Borrego: You can also program the EA to receive only 4 ticks (like it does on the 1min OHLC mode),

No you can't. You can never know which tick will make the high. And you may receive any number of ticks live.

Alberto Gauer Borrego: Only after the close we get that data, but then he says it´s "too late". How 1min delay is too late?

After the close, you now know the high/low/close. But the market has moved on. You can't trade those prices. That is information only,

Alberto Gauer Borrego: Wouldn´t doing this

Doing what?

 
William Roeder #:


Doing what?

Use the tick data of the M1 bar that just closed instead of the current bar.

For example, if the previous bar data allows for a trade it acts like a delayed signal.

You said "you can´t trade those prices", but I don´t need to trade that exact price, I don´t need precise entries. The EA just needs to know if a signal to open a trade was present there, if yes it executes at market. There are no pending orders other than a hard stop created when the trade is open. It uses virtual TP and SL.
 
Alberto Gauer Borrego #:

Use the tick data of the M1 bar that just closed instead of the current bar.

For example, if the previous bar data allows for a trade it acts like a delayed signal.

You said "you can´t trade those prices", but I don´t need to trade that exact price, I don´t need precise entries. The EA just needs to know if a signal to open a trade was present there, if yes it executes at market. There are no pending orders other than a hard stop created when the trade is open. It uses virtual TP and SL.

If im following your logic correctly, you want to have your EA check your conditions immédiately after candle close? Since you say you dont need to trade the exact price or know entries. It wouldn't be too late, as this is mostly just your own preference. There are many ways to trade, right? :) Whatever works for you. 

Currently im using a very simple code to run (part of) my EA as soon as a new candle opens (so it uses info on the candle that just closed):    if(iVolume(NULL,0,0) == 1) { Insert code here }

Mind you, this is MT4 so the MT5 might look a little different. Also, you have to pay mind that the indicators that you use all have to be set to shift 1, since when you use shift 0 they will be functioning on the candle that just opened, with one tick of volume. That wouldnt be good :P

 
Bob #: Currently im using  if(iVolume(NULL,0,0) == 1) { Insert code here }

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.
          MT4: New candle - MQL4 programming forum #3 (2014)
          MT5: Accessing variables - MQL4 programming forum #3 (2022)

I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
          Running EA once at the start of each bar - MQL4 programming forum (2011)

 

Hi William, 

Thanks for the info! You have a good point in volume not being fully dependably. Im going to take your wisdom and review it thoroughly. 

 
William Roeder #:

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.
          MT4: New candle - MQL4 programming forum #3 (2014)
          MT5: Accessing variables - MQL4 programming forum #3 (2022)

I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
          Running EA once at the start of each bar - MQL4 programming forum (2011)

How do i use time like you mention in mt5. I'm trying to mimic the 1min ohlc bars back testing as well and checking for new 1 min bars doesnt seem to work as well. Any advices on mimic 1min ohlc with tick.
 
Bob #:

Hi William, 

Thanks for the info! You have a good point in volume not being fully dependably. Im going to take your wisdom and review it thoroughly. 

Hi William,

Thanks for your insight! You raise a valid point about volume not being fully reliable. I’ll definitely take your advice into consideration and review everything thoroughly. Appreciate it!