Indicator · Pine Script v5 · On the chart

DEBUG Lower TF Supertrend

by g-moe· code credited to goodgains

DEBUG Lower TF Supertrend calculates a modified trailing Supertrend line and trend direction based on average true range bands applied around the bar mid-price.

View on GitHub

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

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

debug-lower-tf-supertrend.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("DEBUG Lower TF Supertrend", overlay = true)

// @keywords: supertrend, lower-timeframe, atr-trail, trend-side, hull-ma, background-highlight, debug-tool, one-minute, atr-multiplier, hl2-bands, trend-flip, mtf-debug, trail-line, bullish-bearish, hma-atr, wma-atr, ema-atr, sma-atr, vwma-atr, side-indicator

// plot(close)

// function to calculate supertrend side
f_mtf_st(st_mult, atr_length, st_type) =>

    float mtf_atr = switch st_type
        "MA" => ta.sma(ta.tr(false), atr_length)
        "WMA" => ta.wma(ta.tr(false), atr_length)
        "VWMA" => ta.vwma(ta.tr(false), atr_length)
        "EMA" => ta.ema(ta.tr(false), atr_length)
        "HMA" => ta.hma(ta.tr(false), atr_length)

    mtf_up = hl2 + (st_mult * mtf_atr)
    mtf_down = hl2 + (-st_mult * mtf_atr)
    
    var float mtf_st = na
    mtf_st := close < mtf_st[1] ? mtf_up : mtf_down

    var int mtf_st_side = na
    mtf_st_side := close > mtf_st ? 1 : close < mtf_st ? -1 : mtf_st_side[1]

    [mtf_st_side,mtf_st]


min1_st_mult = 1.0
min1_st_atr_length = 4
min1_st_avgtype = 'HMA'
min1_st_timeframe = '1'

[min1_st_array, st_value] = f_mtf_st(min1_st_mult, min1_st_atr_length, min1_st_avgtype)


bgcolor(min1_st_array == 1 ? color.new(color.green,50) : min1_st_array == -1 ? color.new(color.red,80) : na)
plot(st_value)

Overview

The custom function supports multiple moving average types, such as HMA, EMA, SMA, WMA, and VWMA, to calculate ATR. The script plots the Supertrend line directly on the price chart and colors the chart background green during bullish conditions and red during bearish conditions. It is designed as a lightweight debugging tool for lower-timeframe trend tracking.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

M1-M5

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

318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
280 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 3 days ago · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
220 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope

More Trend 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