Trading Dev AcademyFree quant education

Free lesson · Charts & patterns

First principles: what a candle actually records

Open interactive lessonPractice calculationsExplore labs

Start with the idea

A candle is a compact record of prices over an interval. Learn its measurable parts before attaching a narrative. A long lower wick means the interval traded much lower than its open and close; the candle alone cannot establish who traded or why.

Symbols, units & horizon
  • O,H,L,C: open, high, low and close in matching price units
  • A: full range, nonnegative
  • B: absolute body length
  • U,D: upper and lower wick lengths
  • b,u,d: dimensionless range fractions
  • CLV: close-location value between −1 and 1
  • | |: absolute value
  • max,min: larger and smaller of their arguments
  • Volume: quantity traded during the defined interval

When and why to use this

Use OHLC checks in data cleaning and dimensionless candle features in a research model. For execution simulation, identify which facts become known only at the interval close.

A candlestick compresses an interval into four traded prices: open, high, low and close (OHLC). Volume adds the amount traded, producing OHLCV. The body spans open to close; a wick extends to each extreme. A rising candle closes above its open and a falling candle below it. Colour is only a display convention. A green candle can still close below yesterday’s close after a downward gap.

A=H−L,B=|C−O|,U=H−max⁡(O,C),D=min⁡(O,C)−L,A=B+U+D
Algebra and arithmetic

Partition the trading range

  1. Suppose C≥O. Then B=C−O, U=H−C and D=O−L. Adding gives C−O+H−C+O−L=H−L.
  2. If C<O, the body is O−C and lower wick is C−L. The same cancellation gives A=H−L. Absolute value and min/max handle both cases.
Work it by hand

O=100,H=106,L=98,C=104: range=8, body=4, upper wick=2, lower wick=2.

Start by comparing body and wick lengths in price units, then divide by the range to compare different prices and timeframes. A tiny range makes ratios unstable; a zero-range bar has no meaningful body/range ratio. A high close within the range is an observation about where trading ended, not direct evidence about hidden buying pressure or the next return.

b=BA,u=UA,d=DA,CLV=2C−H−LH−L
Algebra and arithmetic

Remove scale and centre the close

  1. Divide A=B+U+D by positive A to get b+u+d=1.
  2. The close fraction is (C−L)/A, between 0 and 1. Multiply by 2 and subtract 1: 2(C−L)/A−1=(2C−H−L)/A.
Work it by hand

For the same candle, b=.50, u=.25, d=.25 and CLV=(208−106−98)/8=.50.

A daily bar depends on the session calendar and exchange timezone. Intraday bars depend on boundary rules, auction prints and whether off-session trades are included. Splits and distributions can distort a chart if prices are inconsistently adjusted. OHLC does not reveal the order in which the high and low occurred. If both a stop and a target fall inside one bar, their execution order is unknown without finer data.

Research sources, review dates and limitations

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def candle_geometry(o, h, l, c):
    if not l <= min(o,c) <= max(o,c) <= h:
        raise ValueError("Invalid OHLC ordering")
    span, body = h-l, abs(c-o)
    upper, lower = h-max(o,c), min(o,c)-l
    fractions = None if span == 0 else (body/span, upper/span, lower/span)
    clv = None if span == 0 else (2*c-h-l)/span
    return {"range":span,"body":body,"upper":upper,"lower":lower,
            "fractions":fractions,"clv":clv}

print(candle_geometry(100,106,98,104))

Continue learning

Candles, Structures & Pattern Research — all lessons
  1. First principles: what a candle actually records
  2. Doji, hammer, shooting star and long-body bars
  3. Engulfing, inside bars and multi-candle sequences
  4. Trends, ranges, breakouts and chart structures
  5. Indicators as arithmetic: ATR, moving averages, RSI and bands
  6. Known strategy families: from chart idea to complete rules
  7. Pattern recognition: rules, features, shapelets and image models
  8. Quantitative recognition I: build a causal candle feature table
  9. Quantitative recognition II: shapelets and constrained dynamic time warping
  10. Quantitative recognition III: causal encoders and contrastive learning
  11. Quantitative recognition IV: GAF images, CNNs, transformers and visual-model audits
  12. Quantitative recognition V: calibrate, abstain and test the complete strategy
  13. Research review: what the evidence does and does not establish

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations