The issue is not with the indicator but with the way MetaTrader stores the spread.
MetaTrader (like other platforms) averages the spread during the bar and provides this averaged value in the historical data.
This is problematic on bar opening after a gap (usually on Sunday evening or on Monday morning). The spread can be high for a few seconds or minutes, but then lower later. It results in a low average spread for the bar. However, when we trade, we open a position at the Bar open with a high spread, which may ruin the position.
I have an idea to catch such cases by artificially increasing the spreads of bars after a gap.
I'll gather information on real spreads and gaps, and see what the RealSpread/AverageSpread ratio is for the different symbols and time frames.
The EA Studio backtest works perfectly with the data we feed it.
I'm also considering an advanced data feed with two spreads per bar—one at bar open and one averaged.
...
The spread you set in the Symbol Settings is valid for market data without a real spread. (Data you may import from MetaTrader 4.)