What the spread costs your Expert Advisor, and how to price it in a backtest

Every Expert Advisor I test now carries an input it does not need: the expected cost of a round trip, in points. At zero the strategy trades as if execution were free. Set it to a spread measured from your own quotes and the same code pays for its fills, and the gap between the two runs is the only part of this I would defend.

A round trip pays the spread once, buying at the ask and selling at the bid, and the term is the spread I expect at entry. The number is in points, so it does not move with the lot; the money it costs does, because a point is worth more on a bigger position.

To get the number I sample rather than assume. A timer fires on a fixed interval, reads the spread, and files it under the server hour and weekday, so quiet and busy hours stay in separate buckets. Pool them and the average matches neither.

Without the flag on that read, a symbol whose spread cannot be read contributes a zero you cannot tell from a real one.

From a month of samples I take the mean and the largest spread I saw in each bucket. The mean is the base run, the largest one a second, and I report the pair: a strategy that holds at the mean and fails at the worst reading is a different strategy.

Then the same test twice, the term at zero and then at the measured value, both equity curves kept. If the curves coincide, the term is not reaching the fills; check that before reading anything into the result. If they separate, the gap is what your declared cost adds: on data that carries no spread of its own, that is the whole spread cost; on data that does, it is a second charge on top. Either way it sits beside the gross edge.

Next to a stored result I keep the sampling window, the bucket distribution, the term that was applied, and both runs. A curve without them cannot be reproduced, by a reader or by me in a month.

Test data that already carries its own spread is the one to watch, and a term on top charges the same cost twice. A distribution carried from a quiet month into a loud one describes a market the trades never met. And the term is the cost I declared, never the cost I got; for that, the deals are the evidence that counts.

What does the spread on your symbol read in the hour your Expert Advisor opens most of its trades, and how far is that from the all-day average you would use?

Jevon Naldo Yoshield:
What does the spread on your symbol read in the hour your Expert Advisor opens most of its trades, and how far is that from the all-day average you would use?

Every other day it seems, I find a new use for the MT5-integrated AI Assistant. Recently, I prompted it to scan my backtest report and calculate the average spread incurred. Then I prompted it to discern whether a raw spread/commissions account versus a standard spread account is cheaper for my EA. To my surprise, the standard spread account won in every scenario in at least 80% of the EA's trades.

Not to be smug, but there's little reason to approximate anything anymore with the advent of the AI Assistant.