Different trades taken in strategy tester than in real market conditions

 

Hi, I have a problem using the strategy tester, and am searching for some ideas how to prevent this in the future. 

I'm running a strategy on GBPAUD, which is consistent profitable in backtest. On real market conditions (real account running 24/7) it took a trade, that it did't take in the backtest. (I could validate it one day later, when the newest data was provided to my Roboforex Demo account). I have noticed it, hence it blew my account... And now I'd like to learn from this .

What Happened on Real account, there was a trade taken on 1:15 on strategy tester nothing happened.

I attach a file, hence I get an error, that my post can't be bigger than 64000 characters (but it isn't lol)

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
Files:
 
  • if you backtest in MT5 with "every tick based on real ticks" mode in Metatrader 5 and having different results from real trading so it is very strange/abnormal case for MT5, and it may be related to the bug in your EA;
  • if you backtest in MT4 and having different results from real trading on MT4 so it is norma for MT4.

..and read here for more: Testing trading strategies on real ticks and the explanation is on this post

Testing trading strategies on real ticks
Testing trading strategies on real ticks
  • www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: "1 minute OHLC", "Every tick" and "Every tick based on real ticks" using actual historical data.
 
Sergey Golubev #:
  • if you backtest in MT5 with "every tick based on real ticks" mode in Metatrader 5 and having different results from real trading so it is very strange/abnormal case for MT5, and it may be related to the bug in your EA;
  • if you backtest in MT4 and having different results from real trading on MT4 so it is norma for MT4.

..and read here for more: Testing trading strategies on real ticks and the explanation is on this post

Hi Sergey, 

I updated the description and attached a zipped PDF file with the source code.

I'm not sure if this is related to the event spy or to the new bar handling. Maybe You can see something in the coding.

It could also be a performance problem from the server or some time differences between VPS and broker time...

Best regards

 
forexmaster0 #:

Hi Sergey, 

I updated the description and attached a zipped PDF file with the source code.

I'm not sure if this is related to the event spy or to the new bar handling. Maybe You can see something in the coding.

It could also be a performance problem from the server or some time differences between VPS and broker time...

Best regards

If someone created EA and his backtest is very similar (or same) with his trading by his EA so many traders will ask about the following:
"How did you achive it? Which special coding technique did you use? Or are you trading on daily timeframe close bar and your EA is very simple one?"

So, if it is about Metatrader 4 and you want for your backtest to be the same with your trading with same condition and same EA with same settings - you should ask the coders for help ... or there is the other way: some traders are converting their EAs (which was coded for MT4) to MT5 to backtest them with "every tick based on real tick" mode (and to find the settings for trading by optimization).

Because of the following: backtesting results are the same/similar with trading in case for MT5 (and it is the normal situation for MT5), but not for MT4 sorry.
So, some traders are converting their EAs to MT5 to find good settings and to backtest their EA to get the real and exact results which are same or similar with trading for example.

-----------------------

There is some other problem: many EAs are performing the differently for different brokers (because the quotes/data may be different).
And some indicators are showing/performing differently on the chart (for example: iTrend indicator).
But it is the "other story".

-----------------------

If someone tells me about the following: "I have EA which will be profitable in trading because this EA is backtested with good profit".
I will reply to him:
- MT4 or MT5? Because if MT5 so it may be a true because backtest should similar with trading by default in case of MT5,
and if it is MT4 so - which special coding technique did you use to achive the similarity your trading with backtesting by this EA? Because it should not be the same results by default in case of MT4 ... in case of MT5 - yes, it should be the same results by default ...
- Which broker did you use? Because it may be different results for different brokers, and if you have same results for every or many brokers so which special coding technique did you use to achive this similarity? Because it should not be same by default ...

-----------------------

It is just my opinion because on experience (the other people may have a different opinion but I expessed here my opinion sorry).

 
Sergey Golubev #:

If someone created EA and his backtest is very similar (or same) with his trading by his EA so many traders will ask about the following:
"How did you achive it? Which special coding technique did you use? Or are you trading on daily timeframe close bar and your EA is very simple one?"

So, if it is about Metatrader 4 and you want for your backtest to be the same with your trading with same condition and same EA with same settings - you should ask the coders for help ... or there is the other way: some traders are converting their EAs (which was coded for MT4) to MT5 to backtest them with "every tick based on real tick" mode (and to find the settings for trading by optimization).

Because of the following: backtesting results are the same/similar with trading in case for MT5 (and it is the normal situation for MT5), but not for MT4 sorry.
So, some traders are converting their EAs to MT5 to find good settings and to backtest their EA to get the real and exact results which are same or similar with trading for example.

-----------------------

There is some other problem: many EAs are performing the differently for different brokers (because the quotes/data may be different).
And some indicators are showing/performing differently on the chart (for example: iTrend indicator).
But it is the "other story".

-----------------------

If someone tells me about the following: "I have EA which will be profitable in trading because this EA is backtested with good profit".
I will reply to him:
- MT4 or MT5? Because if MT5 so it may be a true because backtest should similar with trading by default in case of MT5,
and if it is MT4 so - which special coding technique did you use to achive the similarity your trading with backtesting by this EA? Because it should not be the same results by default in case of MT4 ... in case of MT5 - yes, it should be the same results by default ...
- Which broker did you use? Because it may be different results for different brokers, and if you have same results for every or many brokers so which special coding technique did you use to achive this similarity? Because it should not be same by default ...

-----------------------

It is just my opinion because on experience (the other people may have a different opinion but I expessed here my opinion sorry).

The broker is Roboforex, the system is Metatrader 5. I code myself, so just see the wrong input data in the debugger - attached as screenshot in the pdf.

Just from the trading system, it was fine, that the trade was taken in the real enviroment. The problem is, that in the testing mode the algo didn't behave like that.

When I CopyBuffer for the last 3 entries, I consider only entry 2 and entry 1 for comparison. Don't see the problem yet.

Maybe it is in the eventspy logic.

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
  • www.mql5.com
Running MQL5 Program Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: