Indicator · Pine Script v5 · On the chart

HAZZONES

by ashwagamma

This indicator plots support and resistance zones on the price chart using Heikin Ashi data.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code99
Settings13inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago23 Jun 2025

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

99 lines of Pine Script v5 from hazzones.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

hazzones.txt
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ashwagamma

//@version=5
indicator("HAZZONES", overlay = true, max_boxes_count = 500)

maxNumOfSupBoxes = input.int(defval=15, title='Maximum # of Support Zones', minval=1, maxval=500, tooltip='Minimum = 1, Maximum = 500')
maxNumOfResBoxes = input.int(defval=15, title='Maximum # of Resistance Zones', minval=1, maxval=500, tooltip='Minimum = 1, Maximum = 500')
numBullBearHA = input.int(defval = 5, title='Number of bull/bear HA candles', minval=1, maxval=10)
tf = input.timeframe("", "Timeframe")
supBoxColor = input.color(defval=color.new(color.green, 80), title='Support Zone Color', group="Support Zone Style")
supBoxBorderColor = input.color(defval=color.new(color.green, 70), title='Support Zone Border Color', group="Support Zone Style")
resBoxColor = input.color(defval=color.new(color.red, 80), title='Resistance Zone Color', group="Resistance Zone Style")
resBoxBorderColor = input.color(defval=color.new(color.red, 70), title='Resistance Zone Border Color', group="Resistance Zone Style")
showMitigatedZones = input.bool(defval=true, title='Show mitigated zones?', group="Mitigated Zone Style")
mitResBoxColor = input.color(defval=color.new(color.gray, 85), title='Mitigated Resistance Zone Color', group="Mitigated Zone Style", tooltip='Set Transparency to 0 to make mitigated Boxes disappear')
mitResBoxBorderColor = input.color(defval=color.new(color.red, 70), title='Mitigated Resistance Zone Border Color', group="Mitigated Zone Style", tooltip='Set Transparency to 0 to make mitigated Boxes disappear')
mitSupBoxColor = input.color(defval=color.new(color.gray, 85), title='Mitigated Support Zone Color', group="Mitigated Zone Style", tooltip='Set Transparency to 0 to make mitigated Boxes disappear')
mitSupBoxBorderColor = input.color(defval=color.new(color.green, 70), title='Mitigated Support Zone Border Color', group="Mitigated Zone Style", tooltip='Set Transparency to 0 to make mitigated Boxes disappear')

isStrongBullishTrend(o, h, l, c) =>
    ta.barssince(c<=o)-1>=numBullBearHA and numBullBearHA <= ta.barssince(not((c>o and h>c and l-o>-1*(h-l)/10) or ((c[1]>o[1] and h[1]>c[1] and l[1]-o[1]>-1*(h[1]-l[1])/10) and c>=o) or ((c[2]>o[2] and h[2]>c[2] and l[2]-o[2]>-1*(h[2]-l[2])/5) and c>=o and c[1]>=o[1])))

isStrongBearishTrend(o, h, l, c) =>
    ta.barssince(c>=o)-1>=numBullBearHA and numBullBearHA <= ta.barssince(not((c<o and l<c and o-h>-1*(h-l)/10) or ((c[1]<o[1] and l[1]<c[1] and o[1]-h[1]>-1*(h[1]-l[1])/10) and c<=o) or ((c[2]<o[2] and l[2]<c[2] and o[2]-h[2]>-1*(h[2]-l[2])/5) and c<=o and c[1]<=o[1])))    

var box[] _supports = array.new_box()
var box[] _resistances = array.new_box()
int delT = na

[o, h, l, c] = request.security(ticker.heikinashi(syminfo.tickerid), tf, [open, high, low, close])
[sz_open, sz_high, sz_low, sz_close] = request.security(ticker.heikinashi(syminfo.tickerid), tf, [open[ta.barssince(close<=open)], high[ta.barssince(close<=open)], low[ta.barssince(close<=open)], close[ta.barssince(close<=open)]])
[rz_open, rz_high, rz_low, rz_close] = request.security(ticker.heikinashi(syminfo.tickerid), tf, [open[ta.barssince(close>=open)], high[ta.barssince(close>=open)], low[ta.barssince(close>=open)], close[ta.barssince(close>=open)]])
[isStrongBullishTrend, isStrongBearishTrend] = request.security(ticker.heikinashi(syminfo.tickerid), tf, [isStrongBullishTrend(open, high, low, close), isStrongBearishTrend(open, high, low, close)])
[supBoxBarDelta, resBoxBarDelta] = request.security(ticker.heikinashi(syminfo.tickerid), tf, [(ta.barssince(close<=open)), (ta.barssince(close>=open))])


if isStrongBullishTrend and not(isStrongBullishTrend[1]) and barstate.isconfirmed
    box supbox = na
    supbox := box.new(bar_index-supBoxBarDelta, sz_high, bar_index+1, sz_low, xloc = xloc.bar_index, border_color = supBoxBorderColor, bgcolor=supBoxColor)
    if array.size(_supports) > maxNumOfSupBoxes
        box.delete(array.shift(_supports))
    array.push(_supports, supbox)


if isStrongBearishTrend and not(isStrongBearishTrend[1]) and barstate.isconfirmed
    box resbox = na
    resbox := box.new(bar_index-resBoxBarDelta, rz_high, bar_index+1, rz_low, xloc = xloc.bar_index, border_color = resBoxBorderColor, bgcolor=resBoxColor)
    if array.size(_resistances) > maxNumOfResBoxes
        box.delete(array.shift(_resistances))
    array.push(_resistances, resbox)

if array.size(_supports) > 0 and barstate.isconfirmed
    for i = array.size(_supports) - 1 to 0 by 1
        _box = array.get(_supports, i)
        _boxLow = box.get_bottom(_box)
        _boxHigh = box.get_top(_box)
        _boxRight = box.get_right(_box)
        _boxLeft = box.get_left(_box)

        if bar_index == _boxRight
            needMitigate = c < _boxLow and h < _boxLow
            for j = 1 to 4 by 1
                needMitigate := needMitigate and c[j]<_boxLow
            for j = 1 to 2 by 1
                needMitigate := needMitigate and h[j]<_boxLow
            if needMitigate
                if showMitigatedZones
                    box.set_bgcolor(_box, mitSupBoxColor)
                    box.set_border_color(_box, mitSupBoxBorderColor)
                    //array.set(_isSupMitigated, i, true)
                else
                    array.remove(_supports, i)
                    box.delete(_box)
            else 
                box.set_right(_box, bar_index + 1)

if array.size(_resistances) > 0 and barstate.isconfirmed
    for i = array.size(_resistances) - 1 to 0 by 1
        _box = array.get(_resistances, i)
        _boxLow = box.get_bottom(_box)
        _boxHigh = box.get_top(_box)
        _boxRight = box.get_right(_box)
        if bar_index == _boxRight
            needMitigate = c > _boxHigh and l > _boxHigh
            for j = 1 to 4 by 1
                needMitigate := needMitigate and c[j] > _boxHigh
            for j = 1 to 2 by 1
                needMitigate := needMitigate and l[j] > _boxHigh
            if needMitigate
                if showMitigatedZones
                    box.set_bgcolor(_box, mitResBoxColor)
                    box.set_border_color(_box, mitResBoxBorderColor)
                    //array.set(_isResMitigated, i, true)
                else
                    array.remove(_resistances, i)
                    box.delete(_box)
            else
                box.set_right(_box, bar_index + 1)

Overview

HAZZONES detects strong bullish and bearish trends by counting consecutive Heikin Ashi candles that meet specific body and wick conditions. Up to 15 support and 15 resistance zones can be drawn with customizable colors and transparency. Mitigated zones appear in gray when enabled. Zones update based on the selected timeframe and heikin ashi version. It draws directly on the main price chart without separate panes.

Details

Published by

ashwagamma on GitHub

Draws

On the price 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
Maximum # of Support Zonesint15maxNumOfSupBoxes
Maximum # of Resistance Zonesint15maxNumOfResBoxes
Number of bull/bear HA candlesint5numBullBearHA
Timeframetimeframetf
Support Zone Colorcolorcolor.new(color.green, 80)supBoxColor
Support Zone Border Colorcolorcolor.new(color.green, 70)supBoxBorderColor
Resistance Zone Colorcolorcolor.new(color.red, 80)resBoxColor
Resistance Zone Border Colorcolorcolor.new(color.red, 70)resBoxBorderColor
Show mitigated zones?booltrueshowMitigatedZones
Mitigated Resistance Zone Colorcolorcolor.new(color.gray, 85)mitResBoxColor
Mitigated Resistance Zone Border Colorcolorcolor.new(color.red, 70)mitResBoxBorderColor
Mitigated Support Zone Colorcolorcolor.new(color.gray, 85)mitSupBoxColor
Show all 13 settings
SettingTypeDefaultVariable
Mitigated Support Zone Border Colorcolorcolor.new(color.green, 70)mitSupBoxBorderColor
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

Reversal Breakout System

by TamaraKGreen
46 stars

This indicator detects inside candles inside larger parent candles on the price chart. It plots colored boxes around inside and parent candles, fills them with user-adjustable transparency, draws Fibonacci retracement lines and mother candle range lines, and d

Indicator v6 Candlestick patternsBreakout
Updated 8 weeks ago · None stated GitHub repository of Reversal Breakout System

Pro Pattern Al-Sat

by MeridianAlgo
9 stars

This overlay indicator marks bullish and bearish chart patterns on the price chart and can hide either side. Optional filters require agreement from fast and slow EMAs, Supertrend, and ADX, plus volume, RSI, nearby pivot support or resistance, and a user-defin

Indicator v6 Candlestick patternsTrend
Updated 4 months ago · MIT GitHub repository of Pro Pattern Al-Sat

This overlay indicator detects tweezer tops and bottoms and kangaroo-tail pin bars, then draws supply and demand zones from those patterns. It scores each zone, decays freshness, merges overlapping zones, and can invalidate a zone after a close-through or afte

Indicator v6 Candlestick patternsSupport & resistance
Updated 3 days ago · MIT GitHub repository of Tweezer & Kangaroo Zones [WavesUnchained]
7 stars

This indicator plots Smart Money Concepts and price action components directly on the price chart. It highlights bullish and bearish order blocks, multi-timeframe pivot points, market structure swings with key Fibonacci retracement levels (0.618 and 0.786), zo

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Cryptokazancev Strategy Pack

TheStrat Suite

by 345-strategies
5 stars

This indicator implements Rob Smith's TheStrat price action methodology across up to six configurable timeframes. It classifies candles into inside, directional, and outside bars, identifies patterns like hammers, shooters, and failed 2s, and calculates magnit

Indicator v6 Candlestick patternsSupport & resistance Repaints
Updated 4 days ago · MPL-2.0 GitHub repository of TheStrat Suite

Hercules Rewrite

by g-moe
3 stars

Hercules Rewrite is a signal and visual trade management indicator that overlays entry setups directly on the price chart. It detects candle setups based on minimum tick movement and engulfing patterns, filtering entries through parameters like moving averages

Indicator v5 Candlestick patternsTrend
Updated 5 months ago · None stated GitHub repository of Hercules Rewrite

More Support & resistance 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