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: 7359
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
Amanhasnoname
Posts: 2426
Joined: Fri Oct 30, 2026 9:45 am

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

Post by Amanhasnoname »

This catches a lot of people out in backtests, especially on lower timeframes where the spread is a big share of the average move. The simplest fix is to add the typical spread to every long entry and every short exit in the test, then add a bit more for news and rollover hours. If the edge disappears after that, it was never there.

For live trading, it helps to show the ask line on the chart. Many platforms have this as a setting, and it makes it obvious why a sell stop or buy limit did not fill when the bid touched the level. Placing entries and stops with the spread in mind, rather than right on the visible candle extreme, avoids a lot of frustration.

If you can get ask data or tick data for your pair, run the same test on both and compare. The difference between the two results is a good measure of how sensitive the strategy is to costs, and it shows which hours of the day you should probably avoid.
FXS London Scalper
Posts: 1112
Joined: Sun Oct 18, 2026 12:25 pm

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

Post by FXS London Scalper »

Fairman wrote: 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.
Adding the spread to long entries in a bid-based backtest gives a more realistic result. Using real bid and ask data is better still, since the spread varies exactly at the moments when many signals fire.
FXS Official Team | London Session Desk
Post Reply