Indicator · Pine Script v5 · Own pane

Lower Labels

by g-moe· code credited to goodgains

Lower Labels is a cross-asset market structure indicator that plots candles and swing structure labels for a selected secondary symbol in a separate pane.

View on GitHub

Repaints

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code56
Settings6inputs
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

56 lines of Pine Script v5 from Tradingview/lower-labels.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

lower-labels.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("Lower Labels", overlay = false)

// @keywords: lower-labels, swing-high, swing-low, pivot-high, pivot-low, higher-high, lower-high, higher-low, lower-low, market-structure, swing-structure, trend-direction, bull-bear-neutral, external-symbol, cross-symbol, request-security, candle-plot, shape-labels, pivot-labels, value-when

// sd length input
sd_length = input.int(5, title = 'Length', group = 'Settings', inline = '1', minval = 3, maxval = 50)
main_smybol = input.symbol('USDX', title = 'Calculating Symbol', group = 'Settings', inline = '2')
color_candles = input.bool(true, title = 'Color Candles', group = 'Settings', inline = '3')
dashboard_bull =  input.color(color.new(color.green,0), title='Bull', inline='4', group='Settings')
dashboard_bear =  input.color(color.new(color.red,0), title='Bear', inline='4', group='Settings')
dashboard_neutral =  input.color(color.new(color.yellow,0), title='Neutral', inline='4', group='Settings')

// function to get swing h/l, previous swing h/l, and tell trend
f_get_swing_values(sd_length) =>
    
    sh = ta.pivothigh(high, sd_length, sd_length)
    sl = ta.pivotlow(low, sd_length, sd_length)

    csh = ta.valuewhen(ta.pivothigh(high, sd_length, sd_length), high[sd_length], 0)
    csl = ta.valuewhen(ta.pivotlow(low, sd_length, sd_length), low[sd_length], 0)

    psh = ta.valuewhen(ta.pivothigh(high, sd_length, sd_length), high[sd_length], 1)
    psl = ta.valuewhen(ta.pivotlow(low, sd_length, sd_length), low[sd_length], 1)

    hh = sh >= psh
    lh = sh < psh
    ll = sl <= psl
    hl = sl > psl

    var int trend = na
    trend := ((hh and high >= psh) or close > csh) ? 1 : ((ll and low <= psl) or close < csl) ? -1 : lh or hl ? 0 : trend[1]
    // trend := (lh and high > psh) ? 0 : (hl and low < psl) ? 0 : ((hh and high >= psh) or close > csh) ? 1 : ((ll and low <= psl) or close < csl) ? -1 : lh or hl ? 0 : trend[1]

    var int last_signal = na
    last_signal := hh ? 2 : lh ? -1 : ll ? -2 : hl ? 1 : last_signal[1]

    root = syminfo.root

    [sh, sl, psh, psl, csh, csl, hh, lh, ll, hl, trend, root, last_signal]
[sh_main, sl_main, psh_main, psl_main, csh_main, csl_main, hh_main, lh_main, ll_main, hl_main, trend_main, root_main, last_signal_main] = request.security(main_smybol, '', f_get_swing_values(sd_length), lookahead = barmerge.lookahead_on)

[o,h,l,c] = request.security(main_smybol, '', [open, high, low, close], lookahead = barmerge.lookahead_on)

candle_color = color_candles and trend_main == 1 ? dashboard_bull : color_candles and trend_main == -1 ? dashboard_bear : color_candles ? dashboard_neutral : c > o ? dashboard_bull : dashboard_bear

plotcandle(o, h, l, c, title = 'Calcuting Symbol Candles', color = candle_color, wickcolor = candle_color, bordercolor = candle_color)

plotshape(hl_main and sl_main ? l[sd_length] : na, text="HL", title="Higher Low", style=shape.labelup, color=dashboard_bull, textcolor=color.new(#000000,0), location=location.absolute, offset = -sd_length)
plotshape(ll_main and sl_main ? l[sd_length]  : na, text="LL", title="Lower Low", style=shape.labelup, color=dashboard_bear, textcolor=color.white, location=location.absolute, offset = -sd_length)
plotshape(hh_main and sh_main ? h[sd_length]  : na, text="HH", title="Higher High", style=shape.labeldown, color=dashboard_bull, textcolor=color.new(#000000,0), location=location.absolute, offset = -sd_length)
plotshape(lh_main and sh_main ? h[sd_length]  : na, text="LH", title="Lower High", style=shape.labeldown, color=dashboard_bear, textcolor=color.white, location=location.absolute, offset = -sd_length)

Overview

Lower Labels calculates pivot highs and pivot lows to classify market structure patterns including higher highs, higher lows, lower highs, and lower lows, while tracking the overall trend state. Users can configure the swing detection length, target calculation symbol, candle coloring, and trend colors. Note that the indicator uses security calls with lookahead enabled, which causes repainting on historical bars.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

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

SettingTypeDefaultVariable
Lengthint5sd_length
Calculating SymbolsymbolUSDXmain_smybol
Color Candlesbooltruecolor_candles
Bullcolorcolor.new(color.green,0)dashboard_bull
Bearcolorcolor.new(color.red,0)dashboard_bear
Neutralcolorcolor.new(color.yellow,0)dashboard_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

Calculates continuous structural market bias by detecting swing high and low pivots (higher highs, higher lows, lower highs, and lower lows) using configurable left and right bar lookbacks. It assigns weighted values to classified pivots within a rolling windo

Indicator v6 SMC / ICT / price actionTrend
Updated 3 days ago · MIT GitHub repository of Market Structure Advanced [WavesUnchained]
2 stars

This indicator tracks multi-timeframe market structure across up to four user-defined timeframes in a separate pane. It identifies structural changes through Break of Structure (BoS) and Change of Character (CHoCH) events derived from pivot highs and lows. Use

Indicator v6 SMC / ICT / price actionTrend
Updated 2 months ago · None stated GitHub repository of Market Structure MTF Trend [Pt]
575 stars

This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult

Indicator v5 Support & resistanceTrend
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows with Screener

This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm

Indicator v4 TrendSupport & resistance
228 stars

This indicator plots market structure on the price chart by identifying swing highs and lows. It connects these points with lines to visualize trend direction and detect Break of Structure (BOS) when price breaks a prior swing in the current trend. Change of C

Indicator v6 TrendSupport & resistance
Updated 3 months ago · None stated GitHub repository of Market Structure - BOS & CHoCH

Open Source Fractal

by cantolab
183 stars

This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

More SMC / ICT 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