Indicator · Pine Script v5 · Own pane

GrimmHA Indicator

by GreyssonEnterprises· code credited to allanster

An indicator that draws Heikin-Ashi candles in a separate pane, calculated from the open, high, low and close of each bar and coloured green or red by direction.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code72
Settings1inputs
LicenceMIT
Last update2 months ago1 Aug 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

72 lines of Pine Script v5 from strategies/grimmha/pinescript/grimmha.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

grimmha.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © allanster

//@version=5
indicator(title = "GrimmHA-indicator", shorttitle = "GrimmHA-indicator", overlay = false)

// Revision: 2
// Author: @allanster
// Notes: Pine Script v5 update of Pine Script v2 by @samtsui -> https://www.tradingview.com/script/1lgqD3UK-I-Heikin-Ashi-Candle/

haClose = (open + high + low + close) / 4
haOpen  = float(na)
haOpen := na(haOpen[1]) ? (open + close) / 2 : (nz(haOpen[1]) + nz(haClose[1])) / 2
haHigh  = math.max(high, math.max(haOpen, haClose))
haLow   = math.min(low,  math.min(haOpen, haClose))
haColor = haClose > haOpen ? color.new(#26a69a, 0) : color.new(#ef5350, 0)
plotcandle(haOpen, haHigh, haLow, haClose, title = "", color = haColor, wickcolor = haColor, bordercolor = haColor)


C_Len = 14 // ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body

C_BodyHi = math.max(haClose, haOpen)
C_BodyLo = math.min(haClose, haOpen)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ta.ema(C_Body, C_Len)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = haHigh - C_BodyHi
C_DnShadow = C_BodyLo - haLow
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = haOpen < haClose
C_BlackBody = haOpen > haClose
C_Range = haHigh-haLow
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
C_ShadowEquals = C_UpShadow == C_DnShadow or (((math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent) and ((math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent))
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals

patternLabelPosLow = haLow - (ta.atr(30) * 0.6)
patternLabelPosHigh = haHigh + (ta.atr(30) * 0.6)

label_color_neutral = input(color.gray, "Label Color Neutral")
C_DojiNumberOfCandles = 1
C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body
C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body
alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title = "New pattern detected", message = "New Doji pattern detected")
//if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne
//    var ttDoji = "Doji\nWhen the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level."
//    label.new(bar_index, patternLabelPosLow, text="D", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttDoji)
//bgcolor(highest(C_Doji?1:0, C_DojiNumberOfCandles)!=0 ? color.gray : na, offset=-(C_DojiNumberOfCandles-1))

herebedoji = C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne

BullLabel = "Bullish HA"
BearLabel = "Bearish HA"
BullHA = haLow == haOpen and haClose > haOpen and herebedoji[1]
BearHA = haHigh == haOpen and haClose < haOpen and herebedoji[1]

barcolor( BullHA ? color.yellow : BearHA ? color.white :na)

plotshape(BullHA, title="Bullish HA", style=shape.triangleup, location=location.belowbar, color=color.lime, text=BullLabel)
plotshape(BearHA, title="Bearish HA", style=shape.triangledown, location=location.abovebar, color=color.red, text=BearLabel)

// alerts
alertcondition(BullHA, title='Bullish HA Alert', message='{{ticker}} - Bullish HA')
alertcondition(BearHA, title='Bearish HA Alert', message='{{ticker}} - Bearish HA')

Overview

The code also computes candle body and shadow measures such as average body size, shadow ratios and doji tests on the Heikin-Ashi values, which suggests candlestick pattern logic. The only setting is a neutral label colour. The visible code ends before any pattern output.

Details

Published by

GreyssonEnterprises on GitHub

Code credit

allanster, as written in the script's header

Draws

Separate pane below the chart

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.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Label Color Neutralcolorcolor.graylabel_color_neutral
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

Heikin Ashi Delta Smoothed

by lunarticktrading
7 stars

This indicator calculates the difference between Heikin-Ashi close and open values to quantify directional candle spread. It smooths this delta value using a simple moving average and plots the resulting oscillator as a line in a separate pane. Traders can cus

Indicator v6 Oscillators & momentumCandlestick patterns
Updated 2 weeks ago · None stated GitHub repository of Heikin Ashi Delta Smoothed

MTF Heiken Ashi

by jerryinyang
5 stars

This indicator evaluates Heikin Ashi trend direction across three user-defined higher timeframes. It determines directional bias using either manual Heikin Ashi calculations or imported Heikin Ashi ticker data, with an optional wick filter to assess wick perce

Indicator v4 TrendCandlestick patterns
Updated 2 years ago · None stated GitHub repository of MTF Heiken Ashi

CCI + Stoch + HA

by g-moe
3 stars

This indicator combines three momentum and trend analysis tools into a separate pane: a multi-timeframe Commodity Channel Index (CCI), a multi-timeframe Stochastic Oscillator, and a dual-EMA smoothed Heikin-Ashi trend bias displayed as colored dots. Users can

Indicator v5 Oscillators & momentumTrend Repaints
Updated 5 months ago · None stated GitHub repository of CCI + Stoch + HA
1 stars

A Pine v4 indicator in a separate pane that combines many signal modules into one counter-style display for intraday charts. Modules include an adaptive ATR and ADX trend stop on a 4 hour interval, zero-lag EMA crosses on 30 minute, 4 hour and daily frames, Ic

Indicator v4 Oscillators & momentumTrend
Updated 6 months ago · None stated GitHub repository of ARPS Ultimate Signal Framework

DEPV2 A6 MTF HA GUCU

by YuceSezar89
1 stars

This indicator calculates Heikin Ashi scores for multiple multiplier timeframes relative to a signal timeframe. It computes HA power for 2x, 3x, 4x, and 6x the base timeframe (default 15 minutes) using custom HA candle logic and normalizes the close-open range

Indicator v6 TrendCandlestick patterns
Updated 12 days ago · None stated GitHub repository of DEPV2 A6 MTF HA GUCU

Heikin Ashi

by jubayernil
1 stars

This indicator calculates and plots Heikin Ashi candlesticks in a separate pane below the main price chart. It retrieves the open, high, low, and close values of the Heikin Ashi synthetic ticker for the chart's current timeframe. Bullish candles, where the Hei

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of Heikin Ashi

More Candlestick patterns scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers