TradingView backtesting

Heikin Ashi backtests on TradingView: signals and fill prices

Heikin Ashi backtests can use synthetic prices for simulated fills, so their results may differ from a test using standard OHLC. On a Heikin Ashi chart, enable standard OHLC fills in strategy Properties or set fill_orders_on_standard_ohlc = true. Alternatively, run on standard candles and request Heikin Ashi data for signals. Both approaches keep synthetic signals separate from fill prices; neither guarantees live execution or profitable trading.

Review your Pine Script with AI

Why a Heikin Ashi fill can differ from a market price

Heikin Ashi candles transform OHLC data. A synthetic open is the midpoint of the previous HA body, so it can lie outside the current market bar. A backtest that fills a market entry at that synthetic open can therefore assign a price unavailable at that time. The size and direction of the performance error depend on the strategy and dataset; there is no universal inflated win rate.

  • HA close = (current open + high + low + close) / 4.
  • HA open = (previous HA open + previous HA close) / 2.
  • HA high = max(current high, HA open, HA close).
  • HA low = min(current low, HA open, HA close).
Illustrative calculationValueImplication
Previous HA open / close100 / 102Next HA open is 101.
Current standard OHLC110 / 114 / 108 / 112The market bar spans 108 to 114.
Current HA OHLC101 / 114 / 101 / 111A synthetic open fill at 101 is outside that market range.

Enable standard OHLC fills on an HA chart

In the strategy Settings/Properties tab, select the standard OHLC fill mode. TradingView documentation currently uses both "Using standard OHLC" and "Heikin Ashi mode: Standard bars" for this control. In source code, set fill_orders_on_standard_ohlc = true in strategy(). The script below deliberately requires an HA chart: its candle-color signals still use HA open and close. The option changes the emulator fill data, not these variables. This exception works because each HA candle corresponds to one standard time bar. It does not make Renko, Kagi or other non-standard chart backtests use standard fills.

Complete Pine v6 example: HA signals with standard OHLC fillspinescript
//@version=6
strategy("HA signals, standard fills", overlay=true,
     fill_orders_on_standard_ohlc=true,
     default_qty_type=strategy.fixed, default_qty_value=1,
     commission_type=strategy.commission.percent,
     commission_value=0.1, slippage=1)

if not chart.is_heikinashi
    runtime.error("Use a Heikin Ashi chart for this example.")

// These remain synthetic HA values. Costs above are illustrative.
bool bullish = close > open and close[1] > open[1]
bool bearish = close < open and close[1] < open[1]

if barstate.isconfirmed and bullish
    strategy.entry("Long", strategy.long)
if barstate.isconfirmed and bearish
    strategy.close("Long")

Use standard candles and request HA signals explicitly

A standard chart makes the source of each calculation easier to inspect. ticker.heikinashi() creates an HA ticker identifier, and request.security() retrieves its values. The example below uses the same two-candle rule as the first script, but obtains HA open and close from a request. Its ordinary chart variables remain standard prices. Keep the requested timeframe equal to the chart timeframe and leave intrabar recalculation disabled for this comparison. The current HA candle can still change before it closes; lookahead_off alone is not a universal non-repainting guarantee. Changing this example to a higher timeframe requires separate handling of confirmed requested bars. Neither example includes protective exits or a complete trading system.

Complete Pine v6 example: requested HA signals on standard candlespinescript
//@version=6
strategy("Requested HA signals on standard candles", overlay=true,
     default_qty_type=strategy.fixed, default_qty_value=1,
     commission_type=strategy.commission.percent,
     commission_value=0.1, slippage=1)

if not chart.is_standard
    runtime.error("Use a standard chart, such as Candles or Bars.")

string haTicker = ticker.heikinashi(syminfo.tickerid)
[haOpen, haClose] = request.security(haTicker, timeframe.period,
     [open, close], lookahead=barmerge.lookahead_off)

bool bullish = haClose > haOpen and haClose[1] > haOpen[1]
bool bearish = haClose < haOpen and haClose[1] < haOpen[1]

if barstate.isconfirmed and bullish
    strategy.entry("Long", strategy.long)
if barstate.isconfirmed and bearish
    strategy.close("Long")

plot(haClose, "Requested HA close", color=color.orange)

Audit three configurations without changing the signal rule

This is a comparison procedure, not a reported experiment. No backtest performance measurements are supplied here. Save the symbol including exchange, timeframe, session, date range, script inputs, capital, size and execution settings with each export. Use the same history and HA initialization context where possible.

  • Compare signal timestamps before profit. Different signals can indicate mismatched sessions, warmup history or a calculation that still uses the host chart.
  • Inspect entry and exit records, including order type and creation time. Standard market orders normally fill on the next available tick, often the next bar open in a bar-close backtest.
  • Keep cost assumptions identical. A slippage-adjusted simulated fill can fall outside a candle range; this alone does not prove synthetic pricing.
  • A position-dependent strategy can change later signals when fills change. Do not assume the trade count must stay identical across A and B.
ConfigurationSignal dataFill dataPurpose
A: HA chart, standard fill mode offHA chart OHLCSynthetic chart pricesDiagnostic baseline for the fill assumption.
B: HA chart, standard fill mode onHA chart OHLCStandard OHLCCompare with A to inspect the effect of fill data.
C: standard chart with an HA requestRequested HA OHLCStandard chart OHLCCompare signal timestamps and fills with B.

What the fill setting leaves unresolved

If an HA-chart strategy calculates ATR, stops, limit prices or position sizes from its ordinary OHLC variables, those calculations still use HA data after standard fills are enabled. Request standard data explicitly for calculations intended to use market bars, or move the strategy to a standard chart. A data request supplies values; it does not independently choose the broker emulator fill feed. HA low includes the actual bar low in a minimum, and HA high includes the actual high in a maximum. The formula does not erase actual wick extremes. It can extend the synthetic range, while changed entry prices and order levels alter stop behavior. Standard OHLC fills also leave liquidity, spread, queue priority and future market conditions unresolved. Model applicable costs, inspect intrabar assumptions and forward-test the rules before interpreting results.

Where Pineify fits

Pine Script AI Coding Agent

Bring your script and specify which calculations should use HA data or standard OHLC. Ask the Coding Agent to draft the changes, then review the source and rerun the comparison in TradingView.

Also useful: Backtest Deep Report. After correcting the fill assumptions, upload a supported TradingView strategy report for analysis. Keep the chart and strategy settings alongside the report; summary metrics alone cannot verify the source of every fill.

Review your Pine Script with AI

Frequently asked questions

Educational programming examples, not investment advice. The cost and order-size values are illustrative. Simulated fills do not guarantee live execution, and no backtest performance is claimed for these examples.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.