How to avoid negative spread when adjust during MT5 export

General discussion about the Tickstory Lite software package.
Post Reply
shawnsuen
Posts: 4
Joined: Thu Oct 27, 2022 11:40 am

How to avoid negative spread when adjust during MT5 export

Post by shawnsuen »

Dear Support team,

I have been using your previous suggestion to adjust tick spread with below commands to export data to MT5, as I would like to replicate my ECN account's real spreads.

Bars:
{BarBeginTime:yyyyMMdd},{BarBeginTime:HH\:mm\:ss},{Open},{High},{Low},{Close},{BarTickCount},{BarTickCount},{BarMaxSpread*100000-10:F0}
Ticks:
{Timestamp:yyyyMMdd},{Timestamp:HH\:mm\:ss},{BidPrice+0.00005},{AskPrice-0.00005},{BidPrice+0.00005},{BidVolume:F0}

However, this leads to negative spreads for some ticks, e.g. ask price < bid price. How can I avoid the negative spreads? Is there a place that can set mininum value of spreads to be 0?

Please let me know if my question is unclear, and look forward to hearing from you soon!

Thanks,
Shawn

tickstory
Posts: 4883
Joined: Sun Jan 06, 2013 12:27 am

Re: How to avoid negative spread when adjust during MT5 export

Post by tickstory »

Hi Shawn,

I assume the problem lies when importing ticks into MT5 (as opposed to the bar data)? Is MT5 giving you any error when it comes across overlapping bid/ask prices or is it using the data as-is and returning a negative spread in your EA?

One solution might be to make sure that your price adjustments are specified so they don't cause a negative number. Of course, not knowing how much overlap there is going to be a problem. The only solution I can think of is calculating the "absolute"/non-negative price in your EA in MT5. This would be the correct approach given this could also potentially occur in a live environment.

Hope this helps.

Post Reply