TradingView indicator guides

Heikin Ashi Smoothed: Inspect This Two-Line Pine Variant

The script on this page plots two filtered lines, not smoothed Heikin Ashi candles. Both branches use the same EMA length, but their inputs differ: the red “Fast” line starts with hlc3, while the blue “Slow” line starts with a custom haC series. Inspect that mapping before interpreting the names or a crossover.

Inspect the Pine Script

This modified source is not standard Heikin Ashi

The helper starts with q = (open + high + low + close) / 4. Its recursive variable is a = (q + previous a) / 2, replacing a missing previous value with zero. It then calculates haC = (q + a + max(high, a) + min(low, a)) / 4.

Standard Heikin Ashi instead uses the midpoint of the previous synthetic open and close for its open; its close is the current OHLC average. TradingView’s Heikin Ashi guide describes that candle construction. This helper uses current q in its open recurrence and another combination for haC. Calling it standard HA candle math would give the wrong comparison target.

No candles are drawn here. There is no request for a separate standard-price feed. On a Heikin Ashi chart, the chart OHLC inputs are already synthetic, so this helper transforms those synthetic values again. Use a standard candle chart when checking the reference against ordinary OHLC.

Trace the two parallel TEMA branches

For any input x, define E1 = EMA(x, N), E2 = EMA(E1, N) and E3 = EMA(E2, N). The combination T(x) = 3E1 − 3E2 + E3 is the Triple EMA or TEMA construction. The variable names TMA1 through TMA4 in this source do not mean a triangular moving average.

Each branch applies that operation twice and combines the results as 2T(x) − T(T(x)). There are six EMA calculations per branch and twelve in total, not fourteen. These are two parallel branches; the output is not an average smoothed by twelve consecutive EMA stages.

  • Red “HAS - Fast”: x = hlc3. In the helper, this is YASIN1, returned as mavi.
  • Blue “HAS - Slow”: x = haC. This is YASIN, returned as kirmizi.
  • buySignal: the red line crosses above the blue line. sellSignal: the red line crosses below it.

Both branches use N = 55 in the displayed call. “Fast” and “Slow” are retained plot labels, not evidence that one has a universally smaller delay. The subtraction terms compensate response and can overshoot; the result need not remain inside a recent price range like a positive-weight average.

A startup example that exposes the seed effect

Take a hypothetical first loaded candle with open 100, high 104, low 98 and close 102. Then q = 101. Because there is no previous a, the code substitutes zero and obtains a = 50.5. The custom source becomes (101 + 50.5 + 104 + 50.5) / 4 = 76.5. Meanwhile hlc3 = 304/3, approximately 101.333333.

At the first valid observation, the EMA stages seed from their input. The resulting red branch begins at approximately 101.333333 and the blue branch at 76.5. This large initial separation is a consequence of initialization, not a measured market trend or a profitable signal. A crossover also needs a prior relationship; merely starting with red above blue does not create one.

For comparison, if the same candle arrived with previous a = 100, current a would be 100.5 and haC would be (101 + 100.5 + 104 + 98) / 4 = 100.875. The price candle is unchanged; the internal history changes the source. These are arithmetic examples, not historical observations.

The snippet has no warm-up mask. Loading more earlier bars can change the recursive state and later values. There is no guarantee that exactly 55 bars eliminates the seed effect across all stages. Compare the same later bars after loading more history and document the difference.

Cross booleans are not orders or active alerts

The function returns two crossover booleans, but the displayed caller only plots the two lines. It has no signal markers, alertcondition calls, alert calls, strategy orders or bar-close confirmation. A crossover can appear and disappear while the current bar develops.

A request for a two-close hold must define both the original crossover and the continued relationship on the following completed bar. Looking at values two bars ago alone does not prove that the relationship held since then. A new alert must also state whether repeated above/below states should trigger or only transitions should trigger.

Adding ADX is a separate calculation. In Pine’s ta.dmi tuple, the third value is ADX; the first two are positive and negative directional indicators. An RSI, ADX or EMA condition does not supply independent proof of a profitable rule. Define exits, sizing, costs and execution timing before a backtest.

Verify source prices and implementation before strategy use

The literal length 55 applies to every EMA in both branches; there is no settings input in this code. If making it editable, use a positive integer and compare intermediate series as well as final lines. This page establishes no best timeframe, crossover frequency or hit rate.

Start by comparing q, a, haC and hlc3 on a known candle. Then inspect each TEMA stage and the final return order. Confirm whether the intended event uses developing or completed values. A large gap between these two filtered inputs does not identify institutional buying or certify trend strength.

TradingView explains that Heikin Ashi values are synthetic. If extending this into a strategy, distinguish signal values from executable market prices and check the broker emulator’s fill assumptions. A visually smooth plot is not evidence of achievable fills.

Pine Script v6: implementation and limits

Paste the complete indicator into Pine Editor on a standard candle chart. Check the red hlc3-derived line and blue haC-derived line in the Data Window. The source retains its original calculation and initialization; the limitations above are part of interpreting it.

Pine Script v6
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify

//@version=6
indicator(title="Heikin Ashi Smoothed", overlay=true, max_labels_count=500)

// Core HAS — Triple EMA smoothing on modified Heikin Ashi values
p_ta_has(simple int length) =>
    src = ohlc4
    haOpen = 0.0
    haOpen := (src + nz(haOpen[1])) / 2
    haC = (ohlc4 + nz(haOpen) + math.max(high, nz(haOpen)) + math.min(low, nz(haOpen))) / 4
    EMA1 = ta.ema(haC, length)
    EMA2 = ta.ema(EMA1, length)
    EMA3 = ta.ema(EMA2, length)
    TMA1 = 3 * EMA1 - 3 * EMA2 + EMA3
    EMA4 = ta.ema(TMA1, length)
    EMA5 = ta.ema(EMA4, length)
    EMA6 = ta.ema(EMA5, length)
    TMA2 = 3 * EMA4 - 3 * EMA5 + EMA6
    IPEK = TMA1 - TMA2
    YASIN = TMA1 + IPEK
    EMA7 = ta.ema(hlc3, length)
    EMA8 = ta.ema(EMA7, length)
    EMA9 = ta.ema(EMA8, length)
    TMA3 = 3 * EMA7 - 3 * EMA8 + EMA9
    EMA10 = ta.ema(TMA3, length)
    EMA11 = ta.ema(EMA10, length)
    EMA12 = ta.ema(EMA11, length)
    TMA4 = 3 * EMA10 - 3 * EMA11 + EMA12
    IPEK1 = TMA3 - TMA4
    YASIN1 = TMA3 + IPEK1
    mavi = YASIN1
    kirmizi = YASIN
    buySignal = ta.crossover(mavi, kirmizi)
    sellSignal = ta.crossunder(mavi, kirmizi)
    [mavi, kirmizi, buySignal, sellSignal]

// Apply with default length 55
[p_ind_1_fast, p_ind_1_slow, p_ind_1_buySignal, p_ind_1_sellSignal] = p_ta_has(55)

// Plot the two smoothed lines
plot(p_ind_1_fast, "HAS - Fast", color.rgb(242, 54, 69, 0), 1)
plot(p_ind_1_slow, "HAS - Slow", color.rgb(41, 98, 255, 0), 1)
Existing indicator chart preview
Existing visual preview. Verify exact values against the source; the image is not a performance result.

Specify a checkable adaptation in Pineify

Provide the exact custom source recurrence, branch return order, TEMA combination and initialization policy. Request editable length, diagnostics and closed-bar alerts as explicit changes rather than assuming they already exist. Ask for syntax validation, compare intermediate values and define execution assumptions before requesting a strategy.

Open Pine Script AI Coding Agent

Educational indicator analysis. No measured trading performance is established here. Syntax validation does not prove formula equivalence, execution assumptions or profitability.

Implementation questions

No. It is a custom two-line overlay with a modified recursive source and two TEMA-based branches. It does not draw candles or reproduce the standard Heikin Ashi open/close calculation.

The first returned line, plotted red and named HAS - Fast, uses hlc3. The second returned line, plotted blue and named HAS - Slow, uses the custom haC source. Both use the same smoothing length.

None are plotted in this snippet. The helper calculates booleans, but the page’s indicator only plots the two lines. Markers, alerts and orders need separate implementation.

Not in this version. The number is a literal in the helper call, not an input.int control. Edit the call or request an editable version, then validate the resulting source.

The modified open substitutes zero for its missing prior value. That affects haC and its recursive filters. The code does not hide initialization bars, so early separation can be an artifact of the loaded history.

They only establish a change in the ordering of these two calculated series. Confirm timing, test a fully specified rule and account for costs. No reversal probability or historical performance is established here.