How can I account for my broker's variable spread markup in backtesting? MQL5 / Meta Trader 5

 

I downloaded the tickstory data for EURUSD for 2023 and made a custom symbol

My algorithm is set to enter a trade when there is a one pip spread. 

With the custom symbol, the algorithm enters 500 trades.

When I use my broker's data for EURUSD for 2023 and make no other changes, the algorithm doesn't enter a trade at 1 pip, 2 pips, 3 pips, 4 pips, 5 pips. 

It enters 165 trades at 6 pips.

It enters 320 trades at 7 pips.

It enters 860 trades at 8 pips.

So, in order to get 500 trades with my broker's data, the algorithm would have to take trades between 6 and about 8.1 pips. 

How do I reverse engineer this to make my tickstory data to match my broker's data?

Also, how do I optimize my algorithms variables on the tickstory data to match the results from my broker's data?

Thanks in advance,

David

 
dvdadie:

How do I reverse engineer this to make my tickstory data to match my broker's data?

Also, how do I optimize my algorithms variables on the tickstory data to match the results from my broker's data?

Thanks in advance,

David


Oh man, thats a tough one. especially since the condition for your robot to enter is based off spread. spreads are a bitch to emulate when it comes to backtesting. unfortunately i dont have a resolution for you however, I can tell you how i approach spreads\backtest. I get the average spread value from my custom data and use it as a fixed value. Also, I dont trade on the first hour of the new session in forex, since spreads are wild at that time. Of course this has been tested and found it works for me. 
 
Looking for the top forex brokers with MetaTrader 5? Based on our hands-on analysis, we’ve identified 8 best options tailored to specific trading needs. Practical tips from our experts are included.