Advertisement IC Markets

Stress testing a scalping EA with widened spreads

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Stress testing a scalping EA with widened spreads

Post by Fairman »

Stress testing a scalping EA with widened spreads

Most EA backtests use either a fixed spread or the historical spread from the data. Both assume your future costs will look like the past. For a scalping EA, that's a big assumption.

A simple stress test is to rerun the backtest with the spread increased. Add half a pip, then a full pip, to every trade. Or multiply the spread by one and a half and two. Then look at what happens to the results.

If the strategy stays profitable with a meaningfully wider spread, it has a margin of safety. If profit disappears with a small increase, the edge is mostly about costs being low, and any change in broker conditions could wipe it out.

It's also useful to widen spreads only at certain times, like the first minutes after the London open, rollover, or news releases. That shows whether the strategy relies on trading at the worst times for costs.

Slippage deserves a similar test. Add a fixed amount against you on each entry and exit and see how the results change.

None of this tells you whether the strategy will work. It tells you how fragile it is. A strategy that only works under perfect conditions is a risky thing to trade live, because conditions are rarely perfect for long.
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Stress testing a scalping EA with widened spreads

Post by Fairman »

In MT5 you can set a custom spread in the tester settings, which makes the basic test easy. For time based widening, you'd need to modify the EA to add extra cost in testing mode depending on the hour, or use custom tick data with adjusted spreads. That takes more work. In Python backtests it's usually simpler, because you control the fill logic directly. Either way, saving the results for each spread level side by side makes it easy to see where the strategy breaks down. A simple table with spread added, profit factor and average R is enough to see the breaking point.
It’s Fairman :geek:
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Stress testing a scalping EA with widened spreads

Post by Fairman »

A related stress test is removing the best trades. Take the backtest results, drop the top five or ten percent of winners, and see what's left. If the strategy goes from profitable to losing, its results depend on a few big trades, which is fine as long as you understand that. But combined with wider spreads, it gives a picture of how sensitive the strategy is. Strategies that survive both tests are rare, and those are the ones I'd trust more. If a strategy loses its edge once you drop a handful of trades and add half a pip, it probably wasn't much of an edge in the first place.
It’s Fairman :geek:
FXS Prop Desk
Posts: 1572
Joined: Wed Oct 07, 2026 9:52 am

Re: Stress testing a scalping EA with widened spreads

Post by FXS Prop Desk »

Running the backtest at 1.5 and 2 times the normal spread shows how quickly the edge disappears.

If the profit drops to zero at 1.5 times the spread, the strategy has very little margin for bad conditions. A strategy that remains profitable at double the spread is much more robust, even if its normal result is less impressive.
FXS Official Team | The Idea Lab & Strategy
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Stress testing a scalping EA with widened spreads

Post by Fairman »

Widened commission is a stress test people often skip. If the broker raises commission, or you move to a prop firm with higher costs, the strategy's edge shrinks in a way similar to wider spreads. Running the backtest with commission increased by fifty percent or doubled shows how sensitive the results are. For scalping EAs with small targets, commission can be a big share of the cost per trade. If the strategy only survives at today's exact costs, any change in conditions could tip it into losing, and that's a fragile place to be.
It’s Fairman :geek:
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Stress testing a scalping EA with widened spreads

Post by Fairman »

Slippage on stops deserves its own test, separate from the entry spread. In live trading, stops in fast markets often fill worse than the stop price, while entries in normal conditions fill close to the requested price. Adding a fixed amount of extra loss to every stop hit in the backtest, say half a pip or a pip, approximates this. For strategies with many small losers, it can change the results a lot. It's a crude test, but it gives a sense of how much slippage the strategy can absorb before the edge disappears.
It’s Fairman :geek:
Post Reply