Heikin Ashi Smoothed Pine Script — Complete TradingView Guide
The Heikin Ashi Smoothed (HAS) indicator is a trend-following overlay for TradingView that applies triple EMA smoothing to Heikin Ashi price data, producing two crossover lines that identify trend direction with reduced noise. Built using Pine Script v6, it outputs a fast line based on hlc3 and a slow line based on ohlc4, each processed through three cascaded exponential moving averages. When the fast line crosses above the slow line, the indicator fires a buy signal; a crossunder fires a sell signal. The default smoothing length is 55 bars, making it optimal for 4H and daily swing trading on stocks, crypto, and forex. This complete guide covers the HAS formula, parameter tuning, trading strategies, and how to generate the full Pine Script code using Pineify in under two minutes.
What Is the Heikin Ashi Smoothed Indicator?
The Heikin Ashi Smoothed (HAS) indicator is a trend-following overlay that transforms raw OHLC price data into triple-smoothed lines using cascaded EMA calculations on Heikin Ashi values, used to identify trend direction and generate crossover-based entry and exit signals.
The indicator was developed as an enhancement to the standard Heikin Ashi charting technique, which was originally conceived by Munehisa Homma in 18th-century Japan as a way to visualise price momentum. The "smoothed" variant extends this concept by applying modern exponential moving average mathematics — specifically a Triple Moving Average (TMA) construction — to filter out the remaining noise in Heikin Ashi values.
Core Formula
The HAS algorithm operates in two parallel tracks:
- Slow line (kirmizi) — derived from
ohlc4(average of open, high, low, close). A synthetic Heikin Ashi close is computed ashaC = (ohlc4 + haOpen + max(high, haOpen) + min(low, haOpen)) / 4, then three EMA passes produceTMA1. Two more triple EMA passes produceTMA2. The slow line equalsTMA1 + (TMA1 − TMA2), doubling the de-lagging correction. - Fast line (mavi) — the same three-pass TMA construction is applied to
hlc3(average of high, low, close) instead of the synthetic Heikin Ashi close, making it more responsive to price swings.
The variable names originate from Turkish: mavi means "blue" and kirmizi means "red", reflecting the original colour scheme of the two lines.
Applicable Markets and Timeframes
Heikin Ashi Smoothed works on all liquid markets: crypto (BTC, ETH, SOL), forex major pairs (EUR/USD, GBP/USD, USD/JPY), equity indices (SPX, NDX, DAX), and futures (ES, NQ, CL). It performs poorly on illiquid assets with large bid-ask spreads. Best timeframes are 4H, Daily, and Weekly. On shorter timeframes (1-minute to 15-minute), the triple EMA smoothing introduces lag that makes signals arrive too late for scalping purposes. The default length of 55 bars is calibrated for the Daily chart; scale it down to 21 for 4H and 13 for 1H.
Pine Script Code Example
The code below implements the complete Heikin Ashi Smoothed indicator in Pine Script v6. Copy the entire script, open the TradingView Pine Script Editor (click Pine Script Editor at the bottom of your chart), paste the code, and click Add to chart. The indicator overlays two lines directly on the price chart and calculates buy/sell crossover signals automatically.
// 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)
// Heikin Ashi Smoothed calculation
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 // fast line (blue)
kirmizi = YASIN // slow line (red)
buySignal = ta.crossover(mavi, kirmizi)
sellSignal = ta.crossunder(mavi, kirmizi)
[mavi, kirmizi, buySignal, sellSignal]
[p_ind_1_fast, p_ind_1_slow, p_ind_1_buySignal, p_ind_1_sellSignal] = p_ta_has(55)
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)
Parameters
The Heikin Ashi Smoothed indicator has one configurable parameter that controls the smoothing intensity for both lines.
| Parameter | Default Value | Description | Recommended Range |
|---|---|---|---|
| length | 55 | EMA smoothing period applied to both the fast (hlc3) and slow (ohlc4 / Heikin Ashi) lines. All 12 internal EMA layers use this same value. | 8–144 |
- Scalping (5m–15m charts): Use
length = 8–14. Signals are frequent and responsive but may produce more false entries in ranging conditions. - Swing trading (4H–Daily charts): Use
length = 21–55(default 55). The Fibonacci value 55 is the classic setting, balancing lag reduction and noise filtering. - Position trading (Weekly chart): Use
length = 89–144. Signals are rare but align with major trend changes, reducing whipsaws to near zero.
Trading Strategies
Three named strategies demonstrate how to use Heikin Ashi Smoothed crossovers in practice. Each strategy specifies exact entry and exit conditions with numbered steps.
Strategy 1: Classic HAS Crossover Trend Follow
Market environment: Trending (bullish or bearish)
The classic Heikin Ashi Smoothed crossover strategy enters in the direction of the crossover signal and rides the trend until the opposite crossover fires. Pair with **20-period SMA** to confirm trend direction before entry.
Long Entry Conditions:
- Fast HAS line (red) crosses above slow HAS line (blue) —
buySignal == true - Closing price is above the 20-bar Simple Moving Average (price in uptrend)
- Enter at the close of the signal bar
Exit Conditions:
- Fast HAS line crosses below slow HAS line —
sellSignal == true - Or price closes below the 20-bar SMA, confirming trend reversal
Strategy 2: HAS + RSI Filtered Swing Trade
Market environment: Trending with pullbacks
This strategy adds a **14-period RSI** filter to the HAS crossover to avoid buying into overbought conditions or selling into oversold conditions, reducing false signals on the 4H chart.
Long Entry Conditions:
- HAS fast line crosses above slow line —
buySignal == true - RSI (14) is below 70 — not overbought at entry
- RSI is rising (current RSI > previous bar RSI)
- Enter at next bar open to avoid signal-bar slippage
Exit Conditions:
- HAS sell signal fires —
sellSignal == true - Or RSI crosses above 80 (extreme overbought), take profit regardless of HAS
Strategy 3: HAS Breakout with Volume Confirmation
Market environment: Breakout from consolidation
This strategy waits for a HAS crossover that coincides with a volume spike, confirming institutional participation. Use it on the Daily chart for crypto and equity breakout setups. Pair with **20-bar average volume**.
Long Entry Conditions:
- HAS fast line crosses above slow line —
buySignal == true - Current bar volume is greater than 1.5× the 20-bar average volume
- Both HAS lines are sloping upward (fast line value > fast line value 3 bars ago)
- Enter at market close of signal bar
Exit Conditions:
- HAS sell signal fires —
sellSignal == true - Or a 2× ATR trailing stop is hit below the most recent swing low
How to Generate Heikin Ashi Smoothed Pine Script in Pineify
Pineify generates production-ready Pine Script v6 code for the Heikin Ashi Smoothed indicator in under two minutes — no coding experience required.
- 1
Open Pineify
Navigate to https://pineify.app and sign in with your TradingView account to access the Pine Script code generator.
- 2
Click "New Indicator"
From the dashboard, click the "New Indicator" button to open the visual indicator builder where you select indicator types.
- 3
Describe your indicator
In the indicator search or description field, type "Heikin Ashi Smoothed" or "HAS crossover". Pineify identifies the indicator and pre-fills the formula parameters.
- 4
Copy the generated Pine Script
Once the preview renders correctly, click "Copy Code" to copy the complete Pine Script v6 code, including the p_ta_has() function, plots, and built-in buy/sell signal logic.
- 5
Adjust the length parameter
Paste the code into TradingView Pine Script Editor, click "Add to chart", then open indicator Settings to adjust the smoothing length. Start with 55 for daily charts and tune as needed.
Frequently Asked Questions
Related Indicators
Ready to Build Your Own Heikin Ashi Smoothed Strategy?
Pineify generates production-ready Pine Script v6 code for the HAS indicator and hundreds more — no coding required.
Start Generating Pine Script for Free