VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / How AlphaPrime Computes

Heikin Ashi backtests: why the smoothed close is never your fill

A finished Heikin Ashi candle does not repaint, but its open and close are averages that may never have traded. Heikin Ashi backtests overstate results by filling at the Heikin Ashi close and by checking stops on the smoothed high and low. AlphaPrime takes signals from the completed Heikin Ashi candle, fills at the next real price plus slippage, and judges stops on the real bar's high and low.

By · Published · updated · Editorial policy

Contents
  1. Does Heikin Ashi repaint, and why do its backtests look better than live trading?
  2. Which Heikin Ashi prices are real, and which are invented?
  3. Where does a Heikin Ashi backtest see the future?
  4. The colour change is only known at the real close
  5. The Heikin Ashi close is not a fill
  6. Stops on smoothed lows
  7. How does AlphaPrime backtest a Heikin Ashi strategy?
  8. Which Heikin Ashi rules survive real fills, and which do not?
  9. Which markets suit Heikin Ashi strategies?
  10. Frequently asked questions

Does Heikin Ashi repaint, and why do its backtests look better than live trading?

A completed Heikin Ashi candle does not repaint; the forming candle changes with every tick, like any candle. Heikin Ashi backtests look better than live trading for a different reason: they fill orders at the Heikin Ashi close, an averaged price that often never traded, and they check stops against smoothed highs and lows.

A Heikin Ashi candle is a candle whose open, high, low and close are computed from the real bar and from the previous Heikin Ashi candle, so consecutive candles blend into each other and trends show as long runs of one colour. The full calculation and the chart-reading side are on the page about how Heikin Ashi candles are calculated. This page is about one thing: what a backtest engine does with those computed prices, and what AlphaPrime (Valynox) does instead.

The short version: Heikin Ashi is the one synthetic chart that keeps the clock, so its timing problem is small. Its price problem is large, because every one of its four values is a calculated number, and two of them, the open and the close, are the ones backtests love to fill at.

Which Heikin Ashi prices are real, and which are invented?

None of the four is a traded price in the ordinary sense, but the high and low are usually close to real, while the open and close can sit well inside the real bar or even outside the range of trades in that period.

The Heikin Ashi close is the average of the real open, high, low and close. On a trending bar it sits in the middle of the range, far from where the bar actually finished. The Heikin Ashi open is the midpoint of the previous Heikin Ashi open and close (the very first candle uses the real open, so no price is invented to start the series), which means it lags: in a strong up move the Heikin Ashi open sits below the real open, sometimes below the real low of the current bar. The Heikin Ashi high is the highest of the real high, the Heikin Ashi open and the Heikin Ashi close, so it is at least the real high; the low works the same way at the bottom. One side effect catches people out: a real bar can close down while its Heikin Ashi candle is green, because the candle's colour compares two averages, not the bar's open and close.

Heikin Ashi valueHow far from a traded priceWhat goes wrong if a backtest fills there
OpenOften outside the current bar's real range in a trendEntries at prices that did not exist in that bar
CloseMid-range of the real barExits and entries in the middle of a move you had not yet seen finish
HighAt or above the real highTargets look reachable that were not
LowAt or below the real lowStops look untouched that were hit
On a trending bar the Heikin Ashi open sits below the real low and the close sits mid-range. Neither is a price you could have traded.
On a trending bar the Heikin Ashi open sits below the real low and the close sits mid-range. Neither is a price you could have traded. AlphaPrime generation settings · chart type panel

Where does a Heikin Ashi backtest see the future?

In the fill and in the stop. Timing is the smaller issue here, but it is not zero, and it is where the repainting question actually belongs.

The colour change is only known at the real close

Rule: a Heikin Ashi candle exists for the strategy only when the real bar it is computed from has closed. Why: until the real close prints, the Heikin Ashi close is still moving, and a colour change seen mid-bar can disappear before the bar ends. What it avoids: a backtest that acts on the colour the candle ended with, as if that colour had been visible from the start of the bar. That is the repainting people notice live: the candle was green at 10:14:30 and red at 10:15:00, and the backtest only ever saw the red.

The Heikin Ashi close is not a fill

Rule: orders fill at the next real price after the signal, plus slippage, never at a Heikin Ashi value. Why: the Heikin Ashi close is an average of four prices; nobody traded there at the end of the bar. What it avoids: entries and exits at mid-range prices in a trending bar, which systematically improve both legs of every trade. A colour-change rule that enters at the Heikin Ashi close of the first green candle is entering several ticks better than any live trader could, on every trade, in the direction of the move.

Stops on smoothed lows

Rule: stops and targets are judged on the real bar's high and low, stop first when one bar covers both. Why: the Heikin Ashi low can sit below the real low, so a stop checked on it is hit less often than a real stop. What it avoids: a backtest whose stop-outs are rarer than the account's will be.

Hypothetical example

A 15-minute bar on an index future opens at 100, runs to 112, dips to 99, closes at 111. The Heikin Ashi close is the average of 100, 112, 99 and 111, which is 105.5. A colour-change buy filled at the Heikin Ashi close puts you in at 105.5. AlphaPrime confirms the candle at the bar's close and fills at the next real open, around 111 plus slippage. The difference, 5.5 points, is about half the bar's entire range, awarded to the backtest for free.

How does AlphaPrime backtest a Heikin Ashi strategy?

Signals come from completed Heikin Ashi candles; money is settled on the real bars underneath them. The method, rule by rule:

  • The Heikin Ashi candle is confirmed at the real bar's close. Why: its values are final only then. Avoids: acting on a colour the candle did not keep.
  • Market orders fill at the next real bar's open, plus slippage. Why: it is the first price that exists after the signal. Avoids: mid-range fills at an averaged close.
  • Stop and limit orders rest at real prices and fill when a real trade reaches them. Why: the Heikin Ashi range is not the traded range. Avoids: limit fills at prices nobody printed.
  • Stops and targets are judged on the real bar's high and low, stop first. Why: the smoothed low hides real excursions. Avoids: stop-outs that vanish in the test and reappear live.
  • Slippage stays at your normal time-bar figure. Why: Heikin Ashi candles arrive at the clock's pace, not in bursts, so the fast-market doubling used for brick charts is not needed. Real-price fills already remove the main distortion.

Heikin Ashi is the only chart type in this series that keeps your normal slippage; every other one carries a multiplier of at least two, because their bars are confirmed in fast markets by construction, and the reason is explained on the overview of why synthetic-bar backtests cheat. Heikin Ashi's distortion is in price, not in timing, and real-price fills fix price.

Which Heikin Ashi rules survive real fills, and which do not?

Rules that use Heikin Ashi as a trend filter and exit slowly tend to survive. Rules that enter on the first colour change and exit on the next one usually do not, because they were paying themselves half a bar's range on each leg.

  • Trend filter: trade only in the direction of the last few Heikin Ashi colours, with entries and exits from another rule. The averaging does its job (filtering) without touching the fill.
  • Colour run with a real-price stop: enter after a set number of same-colour candles, exit on the first opposite candle, stop on the real low of the entry bar. Honest fills shrink it, but it often keeps a positive expectancy in trending markets.
  • Doji-style indecision exits: a Heikin Ashi candle with a small body and wicks both sides. Workable as an exit, poor as an entry, because by the time it prints the move it signals is half over.
  • Enter on first colour change, exit on next: the classic chart demonstration. With real fills and stops it is usually a coin flip minus costs.

Whatever the rule, the test that matters is the one the overview page describes for every chart type: run it with honest fills, then with a one-bar delay on top. A real edge weakens a little. An averaging artefact collapses. Then weigh costs against the average trade as described on the page about trading costs in backtests.

Which markets suit Heikin Ashi strategies?

Heikin Ashi suits markets and timeframes that trend for many bars at a stretch: index futures on 15-minute to daily bars, major currency pairs on hourly and above, large-cap crypto on 4-hour and daily. It suits them because the averaging rewards persistence. It is a poor fit for range-bound sessions and for scalping timeframes, where the lag in the Heikin Ashi open turns every entry into a late one.

Because Heikin Ashi keeps the clock, it combines cleanly with session rules, time-of-day filters and other time-based tools in a way that brick charts cannot. If you want the smoothing of Heikin Ashi with a bar that also ignores time, Renko bricks are the usual next step, and they bring the timing leak with them.

What this means if you use AlphaPrime: choose Heikin Ashi as the chart type in strategy generation and the rules you write read Heikin Ashi candles, while every fill, stop and target is settled on the real bars. The candles that remain in your strategy's logic are the ones that had finished when the order went out, and the prices in your report are the ones that traded.

Frequently asked questions

Does Heikin Ashi repaint?

Completed candles do not. The current candle changes until the real bar closes, which is true of every candle type; the difference is that a Heikin Ashi colour can flip late in the bar, so a rule evaluated mid-bar sees a different chart from a rule evaluated at the close. AlphaPrime evaluates at the close, so what the strategy saw and what the chart shows afterwards are the same.

Why is my Heikin Ashi strategy profitable in a chart backtest and not in AlphaPrime?

Almost always because the chart backtest filled at the Heikin Ashi close or open. Those are averages that sit in the middle of, or outside, the real bar's range. Moving the fill to the next real price removes an advantage that was never available, and if the strategy depended on it, the profit goes with it.

Where should a stop loss go with Heikin Ashi?

At a real price, judged against real highs and lows. A common choice is a fixed distance below the real low of the entry bar, or an ATR-based distance. Do not set it relative to the Heikin Ashi low; that level may be below any price that traded.

Can I use Heikin Ashi for forex and crypto strategies?

Yes. The calculation and the rules are identical. Crypto on daily and 4-hour bars suits Heikin Ashi trend rules particularly well; the same markets on 1-minute bars suit them particularly badly, because the open's lag is large relative to the move.