Re: How to change broker spreads in MT5 export
Posted: Wed Jul 10, 2024 10:27 am
tickstory wrote: ↑Thu Oct 27, 2022 10:21 pm Hi Shawnsuen,
FX exchanges are not centralized which means you will of course get differences in spreads between brokers. This represents the different set of liquidity and traders that are in the market with that particular broker. In Tickstory's case, this information is coming from Dukascopy which are reputed for having multiple pools of liquidity (i.e. ECN).
To answer your questions:
1) You can modify the 'spread' field that is exported in the MT5 bar export by customizing the Bar and Tick output formats.
For bars, you can specify something like so:
{BarBeginTime:yyyyMMdd},{BarBeginTime:HH\:mm\:ss},{Open},{High},{Low},{Close},{BarTickCount},{BarTickCount},{BarMaxSpread*100000+1:F0}
Note the formula portion highlighted in blue. It will essentially give you the BarMaxSpread (in fractional form), multiply by 100000 to get a integer number, followed by adding a 1 which is an arbitrary value which you would like to add (or subtract) from your spread. (The final ":F0" text is to remove the decimal places from the resulting data which MT5 might not like).
For the the MT5 tick data export, you can do a similar customization like so which will add 1 pip to the Bid price:
{Timestamp:yyyyMMdd},{Timestamp:HH\:mm\:ss},{BidPrice+0.00001},{AskPrice},{BidPrice+0.00001},{BidVolume:F0}
Please refer to our manual for further information about these features.
2) The data is sourced from Dukascopy.
Finally, just as an aside - as you may know, spreads can constantly change even on the same broker. If, for example, a broker gets more clients on-board, they may have much tighter spreads from one year (or hour!) to another. Therefore, it is always best to make sure your strategy is not highly dependent on a particular spread as this will likely indicate that your strategy will not perform as expected in a live environment. This item in our FAQ goes into a bit more detail about how you can approach your back-testing to ensure your EA is not being over-optimized.
Hope this helps.
Hello,
is it possible to multiply the spread values by for instance 0.5? I have managed to multiply the spread of bars with {BarMinSpread*100000*0.5}.
But I ran into a problem with ticks. I tryed {AskPrice-BidAskSpread*0.5} and I got an error of unknown identifier BidAskSpread. It seems that I cant add two variables. Is there an other way?
Thank you!