Indicator · Pine Script v5 · On the chart

Heikin Ashi Buy Sell Arrows

by g-moe· code credited to goodgains

The Heikin Ashi Buy Sell Arrows indicator calculates custom Heikin-Ashi values on the current chart to identify potential trend reversals.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code76
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

76 lines of Pine Script v5 from Tradingview/heikin-ashi-buy-sell-arrows.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

heikin-ashi-buy-sell-arrows.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("Heikin Ashi Buy Sell Arrows", overlay = true)

// @keywords: heikin-ashi, buy-sell-arrows, ha-candles, primary-signals, consecutive-count, arrow-labels, trend-reversal, ha-open-close, signal-arrows, alert-conditions, bar-highlight, ha-high-low, entry-markers, exit-markers, smoothed-candles, direction-change, plotshape-labels, overlay-arrows, ha-logic, streak-count

// def HAclose = ohlc4;
// rec HAopen = compoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
// def HAhigh = Max( high, Max( HAopen, HAclose ) );
// def HAlow = Min( low, Min( HAopen, HAclose ) );
// def haBuy = HAopen <= HAlow;
// def haSell = HAopen >= HAhigh;
// rec count=if haBuy==1 and count[1]==0 then 1 else if haSell==0 and count[1]>=1 then count[1]+1 else 0;
// rec count1=if haSell==1 and count1[1]==0 then 1 else if haBuy==0 and count1[1]>=1 then count1[1]+1 else 0;
// def PrimaryUP = if HAopen <= HAlow and habuy==1 and count[1]==0 then yes else no;
// def PrimaryDOWN = if HAopen >= HAhigh and hasell==1 and count1[1]==0 then yes else no;

// plot ArrowUp = if PrimaryUP then HAlow else Double.NaN;
// ArrowUp.SetDefaultColor(Color.Dark_Orange);
// ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Up);
// ArrowUp.SetLineWeight(5);
// ArrowUp.HideBubble();


// plot ArrowDn = if PrimaryDOWN then HAhigh else Double.NaN;
// ArrowDn.SetDefaultColor(Color.Dark_Orange);
// ArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
// ArrowDn.SetLineWeight(5);
// ArrowDn.HideBubble();


[src_o, src_h, src_l, src_c, src_ohlc4] = request.security(syminfo.ticker, '', [open, high, low, close, ohlc4])

var float haclose = 0.00
var float haopen = 0.00
var float hahigh = 0.00
var float halow = 0.00

haclose := src_ohlc4
haopen  := nz((haopen[1] + haclose[1]) / 2, haclose)
hahigh  := math.max(src_h, math.max(haopen, haclose))
halow   := math.min(src_l, math.min(haopen, haclose))

ha_buy  = haopen <= halow
ha_sell = haopen >= hahigh

var int count   = 0
var int count1  = 0

count := ha_buy==1 and count[1]==0 ? 1 
 : ha_sell==0 and count[1]>=1 ? count[1]+1
 : 0

count1 := ha_sell==1 and count1[1]==0 ? 1 
 : ha_buy==0 and count1[1]>=1 ? count1[1]+1
 : 0

PrimaryUP   = haopen <= halow and ha_buy==1 and count[1]==0 ? true : false
PrimaryDOWN = haopen >= hahigh and ha_sell==1 and count1[1]==0 ? true : false

plotshape(PrimaryUP, title = 'Arrow Up', style = shape.labelup, color = color.green,
 text = 'BUY', textcolor = color.white, location = location.belowbar)

plotshape(PrimaryDOWN, title = 'Arrow Down', style = shape.labeldown, color = color.red,
 text = 'SELL', textcolor = color.white, location = location.abovebar)

var color last_color = color.white
last_color := PrimaryUP ? color.green : PrimaryDOWN ? color.red : last_color[1]
barcolor(color = last_color, display = display.none)


alertcondition(PrimaryUP, "BUY Signal", "BUY Signal")
alertcondition(PrimaryUP, "SELL Signal", "SELL Signal")

Overview

A buy signal is generated when a Heikin-Ashi candle forms with no lower wick following a sell sequence, while a sell signal occurs when a Heikin-Ashi candle forms with no upper wick following a buy sequence. The script plots green BUY and red SELL labels on the price chart at the start of new signal sequences and provides alert conditions for entry notifications.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

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.

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

HA: Heikin-Ashi

by mihakralj
99 stars

This indicator calculates and plots Heikin-Ashi smoothed candlesticks directly on the price chart. It 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 al

Indicator v6 Candlestick patternsTrend
Updated 4 weeks ago · Apache-2.0 GitHub repository of HA: Heikin-Ashi
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

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