Trading Dev AcademyFree quant education

Free lesson · Technical analysis

Heikin-Ashi: smoothed candles are synthetic prices

Open interactive lessonPractice calculationsExplore labs

Start with the idea

Heikin-Ashi replaces ordinary candle values with averages. This changes the displayed path and can introduce lag.

Symbols, units & horizon
  • O_t,H_t,L_t,C_t: real bar prices in matching units
  • superscript HA: derived Heikin-Ashi value, not an executable quote
  • t−1: prior completed bar
  • max,min: enclosing high and low

When and why to use this

Use synthetic-bar persistence as a candidate trend-state feature, with a real-price execution ledger.

  • Compute the synthetic close from the current real OHLC average. Compute the synthetic open from the preceding Heikin-Ashi open and close.
  • Seed the first synthetic open explicitly; this lesson uses the first real open/close midpoint.
  • The synthetic high/low enclose both synthetic open/close and the real extremes.
  • Repeated same-color synthetic candles may describe persistence in the smoothing rule. Test a trend filter against simpler moving averages.
  • Use Heikin-Ashi only for features or visualization; reconcile orders and fills with real executable prices.
  • Never backtest fills at synthetic opens, closes or intermediate prices merely because the chart displays them.
CtHA=Ot+Ht+Lt+Ct4,OtHA=Ot−1HA+Ct−1HA2,HtHA=max⁡(Ht,OtHA,CtHA),LtHA=min⁡(Lt,OtHA,CtHA)
Specified chart rule · derivation and arithmetic

Heikin-Ashi: smoothed candles are synthetic prices

  1. For real OHLC [100,106,98,104], synthetic close=(100+106+98+104)/4=102.
  2. If previous HA open=99 and close=101, the current HA open=(99+101)/2=100.
  3. Synthetic high=max(106,100,102)=106; low=min(98,100,102)=98.
Work it by hand

The displayed close 102 differs from the real close 104. A feature may use 102; a fill requires a real price available after the decision.

Use the rule

  • Fix the definition, units and information timestamp.
  • Compute the example and inspect the graph.
  • Compare with a simple baseline on untouched periods after costs.

Before moving on

Write the exact rule, its availability time, an invalidation condition and a fair out-of-sample test.

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 heikin_ashi(bars):
    result=[]
    for o,h,l,c in bars:
        if not l<=min(o,c)<=max(o,c)<=h: raise ValueError("Invalid OHLC")
        close=(o+h+l+c)/4
        opening=(result[-1][0]+result[-1][3])/2 if result else (o+c)/2
        result.append((opening,max(h,opening,close),min(l,opening,close),close))
    return result

print(heikin_ashi([(100,106,98,104)]))

Continue learning

Technical Analysis: Geometry, Structure & Evidence — all lessons
  1. Support, resistance and reversal: start with a price zone
  2. Breakout detection, false breaks and retests
  3. Fibonacci retracements: anchors before ratios
  4. Harmonic patterns: ratio constraints and competing candidates
  5. Elliott Wave: count hypotheses, rules and invalidation
  6. Fair value gaps (FVG): three-bar geometry and fill measurement
  7. Heikin-Ashi: smoothed candles are synthetic prices
  8. Renko: price-driven bricks and the missing time axis
  9. Dynamic support, trend lines and Gann angles
  10. Momentum indicators, oscillators and divergence
  11. Volume, supply/demand zones and what OHLCV cannot reveal
  12. Market structure, BOS and CHOCH as a state machine
  13. Moon phases: encode a calendar hypothesis and try to falsify it

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