Indicator · Pine Script v6 · On the chart

HA: Heikin-Ashi

by mihakralj

This indicator calculates and plots Heikin-Ashi smoothed candlesticks directly on the price chart.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code19
Settings0inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

19 lines of Pine Script v6 from lib/core/ha/ha.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

ha.pine
// HA: Heikin-Ashi
// Smoothed candle transformation with recursive open
// HA_Close = (O + H + L + C) / 4
// HA_Open  = (prev_HA_Open + prev_HA_Close) / 2
// HA_High  = max(H, HA_Open, HA_Close)
// HA_Low   = min(L, HA_Open, HA_Close)

//@version=6
indicator("HA: Heikin-Ashi", overlay=true)

var float haOpen  = na
var float haClose = na

haClose := (open + high + low + close) * 0.25
haOpen  := na(haOpen) ? (open + close) * 0.5 : (haOpen + haClose[1]) * 0.5
haHigh   = math.max(high, haOpen, haClose)
haLow    = math.min(low,  haOpen, haClose)

plotcandle(haOpen, haHigh, haLow, haClose, "HA", color=haClose >= haOpen ? color.green : color.red)

Overview

HA: Heikin-Ashi derives the smoothed close from standard price averages and recursively computes the open, high, and low values. The script does not issue trade signals or alerts, coloring candles green when the close equals or exceeds the open and red otherwise. It contains no configurable input settings. A notable limitation is that it provides only visual candle transformations without automated trade rules or customizable smoothing parameters.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Candlestick patterns, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

All Candlestick Patterns

by shunjizhan
292 stars

All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of All Candlestick Patterns
257 stars

This indicator detects a large set of classic candlestick patterns and plots colored labels on the price chart. Trend context uses a 50-period simple moving average, or the 50 and 200 averages stacked together, and can be switched off. Users filter bullish, be

Indicator v4 Candlestick patternsTrend
Updated 6 weeks ago · None stated GitHub repository of Snag - All Candlestick Patterns

Five-in-one Strategy

by capissimo
114 stars

Five-in-one Strategy combines five analytical tools into a single price chart overlay: the Dual Thrust Trading Algorithm (DTTA), Semafore, HalfTrend, Nick Rypock Trailing Reverse, and Tweezer or Kangaroo Tail candlestick patterns. It generates trade signals us

Indicator v4 TrendBreakout Repaints
Updated 1 year ago · None stated GitHub repository of Five-in-one Strategy
55 stars

This indicator overlays on the price chart and provides trend and momentum analysis. It calculates and plots three exponential moving averages with fixed periods of 20, 50, and 200 using yellow, orange, and blue colors respectively. The script also computes th

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · Apache-2.0 GitHub repository of Trend & Momentum Analysis

Confluence Suite

by TamaraKGreen
46 stars

The Confluence Suite indicator draws multiple trading signals and tools directly on the price chart. It generates entry and exit signals based on selected modes and filters, with an AI signal classifier rating quality from 1-4. Additional features include smar

Indicator v5 TrendSMC / ICT / price action
Updated 7 weeks ago · None stated GitHub repository of Confluence Suite

Abandoned Baby - Bullish

by TWODS-CAPITAL
37 stars

This indicator identifies the Bullish Abandoned Baby candlestick pattern directly on the price chart. The three-bar reversal pattern consists of a strong down candle during an established downtrend, followed by a lower gapping doji candle, and completed by an

Indicator v5 Candlestick patternsTrend
Updated 3 years ago · MIT GitHub repository of Abandoned Baby - Bullish

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers