Heikin Ashi Backtest on TradingView: Why Results Skew
Backtesting a strategy directly on a TradingView Heikin Ashi chart skews returns because haOpen and haClose are smoothed synthetic averages that never trade on the order book — by default, the broker emulator fills orders at those phantom prices instead of real OHLC market prices. To measure a Heikin Ashi rule realistically, either enable fill_orders_on_standard_ohlc=true in strategy() or, better yet, stay on a standard OHLC candlestick chart and compute Heikin Ashi signals inside Pine Script.
Run the clean standard-OHLC Heikin Ashi Pine v6 strategy from this guide directly in the free online strategy judge on BTCUSDT 1D (0.10% fee per side, final 20% sealed).
Published on 1 December 2026. Educational guide and research on past data, never investment advice.
1. The math behind phantom Heikin Ashi fills
Every Heikin Ashi candle is built from smoothed formulas:
haClose = (open + high + low + close) / 4haOpen = (haOpen[1] + haClose[1]) / 2haHigh = max(high, haOpen, haClose)haLow = min(low, haOpen, haClose)
Notice what happens during a strong up-move: haOpen starts near the midpoint of the previous candle, well below the actual market opening price of the new bar. When a trend-following strategy buys on a Heikin Ashi chart without real-OHLC fills:
- Entries get filled below the real market open (a phantom discount you could never execute on an exchange).
- Exits on reversal candles get filled above the real drop because
haOpenlags downward moves as well. - Across 100+ trades, that synthetic entry/exit gap compounds into dramatic paper profits that vanish the instant the strategy runs on standard candlesticks.
2. Option A: fill_orders_on_standard_ohlc=true in TradingView
TradingView added a header flag specifically to stop synthetic fills when the user switches the chart display to Heikin Ashi:
//@version=6
strategy("HA Chart With Real OHLC Fills", overlay=true,
fill_orders_on_standard_ohlc=true,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
commission_type=strategy.commission.percent,
commission_value=0.1)
This is a major improvement over the default, but it has two practical drawbacks:
- Your strategy still depends on whichever chart type the user currently clicked in the TradingView toolbar.
- Exporting or replaying the script in another engine that only accepts standard OHLC bars changes what open and close refer to inside the conditions.
3. Option B (recommended): compute Heikin Ashi manually on a standard OHLC chart
The cleanest, portable Pine v6 design keeps the chart on standard candlesticks at all times, computes haOpen and haClose in four lines of plain Pine math, and lets every fill execute on real OHLC bars with explicit fees (0.1%) and barstate.isconfirmed:
//@version=6
strategy("Heikin Ashi Trend on Standard OHLC", overlay=true,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
commission_type=strategy.commission.percent,
commission_value=0.1)
// Compute Heikin Ashi values manually on a standard OHLC chart (real fill prices)
haClose = (open + high + low + close) / 4.0
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2.0 : (haOpen[1] + haClose[1]) / 2.0
emaTrend = ta.ema(close, 50)
haBull = haClose > haOpen
haBear = haClose < haOpen
enterLong = haBull and haBear[1] and close > emaTrend
exitLong = haBear and haBear[1]
if barstate.isconfirmed and enterLong and strategy.position_size == 0
strategy.entry("Long", strategy.long)
if barstate.isconfirmed and exitLong and strategy.position_size > 0
strategy.close("Long")
Why this pattern beats request.security(ticker.heikinashi(...))
- Zero chart-type ambiguity:
open,high,low,closeare always real exchange prices, and fills are always real OHLC fills. - No
request.security()lookahead or repainting traps (see How to Fix Repainting in Pine Script). - 100% portable: works identically in TradingView, in the free online judge (
sa-pine-vmv3), and in Strategy Arena Lab.
4. Real sealed-period test on BTCUSDT (sa-pine-vm v3, 1 December 2026)
Running the exact standard-OHLC script above on BTCUSDT with 0.10% fees per fill and the final 20% kept sealed (sa-pine-vm v3):
| Timeframe | Training trades / return | Sealed period | Sealed trades | Sealed return vs Buy & Hold | Max drawdown vs Buy & Hold | Verdict |
|---|---|---|---|---|---|---|
1D |
126 trades / +859.33% |
2024-12-17 → 2026-10-16 |
29 | +0.56% vs -23.25% |
15.58% vs 52.97% |
Inconclusive |
4h |
284 trades / -18.01% |
2026-03-12 → 2026-10-17 |
68 | -4.66% vs +15.83% |
19.68% vs 29.25% |
No edge evidence |
On 1D, the trend filter + two-bar HA exit cut maximum drawdown sharply (15.58% vs 52.97% holding) during a -23.25% sealed BTC window, but without statistically conclusive excess return — and on 4h, transaction costs over 68 trades turned the same smoothing rule negative (-4.66%). That gap is exactly what synthetic Heikin Ashi fills hide on a standard TradingView chart.
5. Checklist before trusting any Heikin Ashi strategy
- Switch the chart back to Standard Candles and verify
fill_orders_on_standard_ohlc=trueor computehaOpen/haClosemanually. - Add realistic
commission_value(e.g.0.1% per side on spot crypto) and check fee sensitivity with the TradingView fee calculator. - Test on a sealed period you did not optimize on: free online strategy judge or free TradingView CSV audit dossier preview.
- If your script fires 0 trades after moving back to standard OHLC, check our 8 causes of 0-trade Pine strategies.
- Compare across 8 markets in the cross-market observatory and our 29 open Pine scripts.
⚠️ Disclaimer — This article is for informational and educational purposes only. It does not constitute investment advice or a buy/sell recommendation. Past performance does not guarantee future results. Strategy Arena is an educational simulator with virtual capital. Always do your own research before making investment decisions.