Advertisement IC Markets

Which price closes the bar: bid, ask, or something else

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

Which price closes the bar: bid, ask, or something else

Post by Fairman »

Which price closes the bar: bid, ask, or something else

Most platforms build candles from bid prices. The close of the bar is the last bid in that minute. Buy trades fill at the ask, which sits a spread higher.

That asymmetry makes a mess of simple backtests. A long entry at the close price in the tester is a fill at a price that could not have been obtained, since a real buy would be at the ask. A short entry is more accurate on the entry but then must be closed at the ask.

For a wide spread pair the difference is large. For a narrow spread pair in calm conditions it is tiny, but widening spreads at news or rollover can turn a theoretical profit into a loss.

Some data sources offer both bid and ask series. Testing with the proper side for each action, buys at ask and sells at bid, is the honest way to do it.

A quick check: take a handful of live trades, look at the bar in which each filled, and compare the fill to the bar's close and range. The relationship shows how far the assumption is from reality.

A related detail is how the open of the next bar relates to the previous ask. On a wide spread moment, the new bar can open a pip above the old close without any real price change, simply because the bid and ask shifted. Charts on bid only hide that.

Which side of the quote does the backtest use for entries and exits?
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Post Reply