Indicator · Pine Script v6 · Own pane

High - Low

by SiegerTerpstra· code credited to sajjetti

High - Low measures the price range between the high and low of each bar to analyze market volatility and price expansion or contraction.

View on GitHub

GitHub stars5on the repository
Pine versionv6current
Lines of code108
Settings2inputs
LicenceNone statedfile: MPL-2.0
Last update9 months ago14 Jan 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

108 lines of Pine Script v6 from 4 - HML (v6).pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

4 - HML (v6).pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sajjetti

//@version=6

//-------------------------------------

// Release:                     2020-08-05
// Update:                      2025-12-29
// Author:                      sajjetti
// Email:                       contact@sajjetti.ai
// Website:                     sajjetti.ai
// Profile:                     https://www.tradingview.com/u/stmd/
// Pineversion:                 6
// Filename:                    4 - HML (v6).pine

//-------------------------------------
// PURPOSE
// High Minus Low (HML) indicator - measures the range between high and low
// prices for each bar. Used to analyze volatility and price expansion/contraction.

//-------------------------------------
// FEATURES
// - Multi-timeframe support via Indicator Timeframe input
// - Histogram showing per-bar high-low range
// - Moving average line for smoothed range analysis
// - Dynamic color based on rising/falling values

//-------------------------------------
// NOTES
// - Higher values = larger candle bodies / higher volatility
// - Lower values = smaller candles / consolidation
// - MA line helps identify average volatility over period
// - Useful for detecting breakout potential
// - Compare current range to MA for relative volatility

//-------------------------------------
// INDICATOR PARAMETERS

vVersion                        = "V2.0"
vPineVersion                    = "ps6"
vTitle                          = "High - Low"
vShort                          = "HML"
vOverlay                        = false
vPrecision                      = 0

indicator( title = vTitle+" ["+vVersion+"|"+vPineVersion+"]", shorttitle = vShort+" ["+vVersion+"|"+vPineVersion+"]", overlay = vOverlay, precision = vPrecision )

//-------------------------------------
// INPUTS

var groupHml                    = "HML (Standard: 9)"

vTimeframe                      = input.timeframe( defval = "", title = "Indicator Timeframe" )
vLength                         = input.int( defval = 9, minval = 1, maxval = 1024, title = "Length", group = groupHml )

//-------------------------------------
// COLORS

cHistogramBullish               = #0000b3
cHistogramBearish               = #6666ff
cLine                           = #b30086

//-------------------------------------
// FUNCTIONS

// @function    Simple Moving Average
// @param       n (int) Offset for lookback starting point
// @param       s (series float) Source data
// @param       l (int) Length of the averaging period
// @returns     (float) Average value over the specified period
fMa( n, s, l ) =>
    r = float( 0 )
    for i = 0 to ( l - 1 )
        r := ( r + s[ n + i ] )
    a = r / l
    a

// @function    Calculate HML histogram and line for MTF support
// @returns     (tuple) Histogram and MA line values
fCalcHml() =>
    histogram = high - low
    line      = fMa( 0, histogram, vLength )
    [ histogram, line ]

// @function    Determines histogram color based on trend direction
// @param       n (int) Offset for comparison
// @param       s (series float) Source data to evaluate
// @returns     (color) Dark blue if rising, light blue if falling
fColor( n, s ) =>
    r = ( s[ n + 1 ] < s[ n ] ) ? cHistogramBullish : cHistogramBearish
    r

//-------------------------------------
// CALCULATIONS

[ vHighLowHistogram, vHighLowLine ] = if vTimeframe == ""
    fCalcHml()
else
    request.security( syminfo.tickerid, vTimeframe, fCalcHml() )

//-------------------------------------
// PLOT

vPlotHighLow                    = plot( vHighLowHistogram, style = plot.style_columns, color = fColor( 0, vHighLowHistogram ), title = "HML - Histogram" )
vPlotHml                        = plot( vHighLowLine, style = plot.style_line, color = cLine, title = "HML - Line" )

//-------------------------------------

Overview

High - Low plots a histogram representing the per-bar high-low range along with a simple moving average line to highlight smoothed range trends. Bars are dynamically colored based on whether the range value is rising or falling. The script supports multi-timeframe analysis via user inputs and allows customization of the moving average length. It renders in a separate indicator pane below the main price chart.

Details

Published by

SiegerTerpstra on GitHub

Code credit

sajjetti, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Volatility & bands

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

tradingviewindicatorindicators

Settings

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

SettingTypeDefaultVariable
Indicator TimeframetimeframevTimeframe
Lengthint9vLength
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

This indicator calculates the distribution of close-to-close percentage changes using rate of change on closing prices. It bins percentage changes into intervals of 0.25 percent increments from negative to positive values and plots a normalized cumulative hist

Indicator v4 Volatility & bands
Updated 10 days ago · GPL-3.0 GitHub repository of Close-to-Close % Change Distribution

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
330 stars

This indicator plots candle range and open-to-close movement as percentages in a separate pane. Range is the high-low difference divided by the low, and change is the close-open difference divided by the open. Both series draw as columns. Teal columns show ran

Indicator v5 Volatility & bands
Updated 2 months ago · None stated GitHub repository of Percent & Volatility [Alorse]

Mojito v3 Strategy

by namuan
318 stars

The Mojito v3 Strategy indicator evaluates volatility term structure by calculating the ratio between front-month and second-month VIX futures contracts. It smooths this ratio using a configurable median filter and compares the result against user-defined uppe

Indicator v5 Volatility & bands
Updated 2 months ago · MIT GitHub repository of Mojito v3 Strategy

Function - Logistic Equation

by ricardosantos79
261 stars

Calculates dynamic modeling values by applying a mathematical logistic differential equation to price change over a specified lookback length. It measures price momentum relative to the recent high-low price range. The script plots positive and negative logist

Indicator v5 Oscillators & momentumVolatility & bands
Updated 4 years ago · None stated GitHub repository of Function - Logistic Equation

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V

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