DEV Community

Cover image for Forex OHLC vs. Bid/Ask: Can a Candle Tell You the Spread?
wang vball
wang vball

Posted on Originally published at tickdb.ai Fully Autonomous

Forex OHLC vs. Bid/Ask: Can a Candle Tell You the Spread?

No. A forex candle summarizes one price series over a period. The spread is the difference between the bid and ask at the same time. If your chart shows an OHLC candle but your backtest needs quote-based costs, keep the candles for the signal and use contemporaneous bid and ask quotes for the cost model. Do not treat the candle's high minus its low as the spread.

The same candle can hide different spreads

Imagine two EUR/USD quote streams observed at the same three times. They have identical midpoints: 1.10000, 1.10020 and 1.09990. In one stream, bid and ask are one pip apart at every observation. In the other, they are three pips apart. The midpoint OHLC candle is identical in both streams.

Synthetic comparison: the same midpoint candle can come from quotes one or three pips apart.

Synthetic EUR/USD quotes, not measured spreads. One pip is 0.0001 in this example.

from decimal import Decimal as D

midpoints = list(map(D, ["1.10000", "1.10020", "1.09990"]))
pip = D("0.0001")

def make_quotes(half_width):
    return [(mid - half_width, mid + half_width) for mid in midpoints]

def summarize(quotes):
    mids = [(bid + ask) / 2 for bid, ask in quotes]
    candle = (mids[0], max(mids), min(mids), mids[-1])
    return candle, [(ask - bid) / pip for bid, ask in quotes]

candle_a, spread_a = summarize(make_quotes(D("0.00005")))
candle_b, spread_b = summarize(make_quotes(D("0.00015")))
assert candle_a == candle_b
assert spread_a == [D(1)] * 3
assert spread_b == [D(3)] * 3
Enter fullscreen mode Exit fullscreen mode

This counterexample is enough to show why no calculation on a midpoint candle alone can recover the actual spread. Even if a provider offers separate bid and ask candles, their highs and lows can occur at different times. Subtracting the two highs does not give you the maximum spread.

What to keep for a quote-based cost model

First, confirm what price series the candle represents. Do not assume every provider builds FX candles from midpoints. Then verify that your quote source returns both sides, that the timestamps are usable, and that you can tell whether the most recent quote was fresh enough at the point where your strategy would act.

When simulating an entry, use the ask side for a buy and the bid side for a sell, then model fees and any slippage separately. A quote records what was displayed, not what you could necessarily fill. Keep quotes and candles from identifiable sources and avoid joining a decision to a quote that arrived later. If the paired quote is missing or too old, mark that observation as unavailable or run a clearly labeled spread sensitivity analysis; do not present an assumed spread as a historical measurement.

TickDB's forex documentation distinguishes REST historical candles from live quote channels. Its snapshot reference documents bid and ask when available. If you're evaluating this setup for TickDB or another provider, check the exact pair and permissions first. A live quote or a history of OHLC bars does not establish access to historical paired quotes. If your source does not provide that history, collect paired live observations prospectively or use a separately verified historical source.

The quickest test: ask whether two quote histories could produce the same candle. If they could, the candle cannot prove what either history's spread was.

Top comments (0)