Indicator · Pine Script v5 · On the chart

Trend Strength Signals Enhanced

by haydarkadioglu· code credited to AlgoAlpha

This indicator measures trend strength with Bollinger Bands.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code92
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago17 Feb 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

92 lines of Pine Script v5 from indicators/trend-strength/trend_strength.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

trend_strength.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha
// Modified and Enhanced

//@version=5
indicator("Trend Strength Signals [Enhanced]", "𝑻𝒓𝒆𝒏𝒅 𝑺𝒕𝒓𝒆𝒏𝒈𝒕𝒉 𝑬𝒏𝒉𝒂𝒏𝒄𝒆𝒅", true)

// ============================================================================
// INPUT PARAMETERS
// ============================================================================
c = input.bool(true, "Enable Cloud", group="Display")
lenn = input.int(20, "Period", minval=5, maxval=100, group="Settings")
mult = input.float(2.5, "Standard Deviation Multiplier for TP", minval=1.0, maxval=5.0, step=0.1, group="Settings")
tc = input.int(25, "Gauge Size", minval=3, maxval=50, group="Display")
upColor = input.color(#00ffbb, "Up Color", group="Colors")
downColor = input.color(#ff1100, "Down Color", group="Colors")

// ============================================================================
// GAUGE FUNCTION
// ============================================================================
t = table.new(position.middle_right, 3, tc+1)

printTable(txt, col, row, color, txt1, col1, row1, color1) =>  
    table.cell(t, col, row, txt, bgcolor = color)
    table.cell(t, col1, row1, txt1, bgcolor = color1, text_color = color.white)

// ============================================================================
// TREND CALCULATION
// ============================================================================
len = lenn
src = close

basis = ta.sma(src, lenn)
upper = basis + ta.stdev(src, len, true)
lower = basis - ta.stdev(src, len, true)

upper1 = basis + ta.stdev(src, len, true) * mult
lower1 = basis - ta.stdev(src, len, true) * mult

var trend = 0

if src > basis and src > upper
    trend := 1
if src < basis and src < lower
    trend := -1

// ============================================================================
// PLOTTING
// ============================================================================
pu = plot(upper, "Upper Line", color.new(chart.fg_color, 80), display = c ? display.all : display.none)
pl = plot(lower, "Lower Line", color.new(chart.fg_color, 80), display = c ? display.all : display.none)

barcolor(src > upper ? upColor : src < lower ? downColor : chart.fg_color)

// Gradient calculation
grad = math.abs(basis - src) / (ta.highest(basis - src, 200)) * 100
grad1 = math.min(grad, 40)
grad1 := 100 - grad1

xMax = 100
xMin = 0
range_ = xMax - xMin
y = 1 - grad / range_
y := y > 100 ? 100 : y < 0 ? 0 : y

fill(pu, pl, color.new(chart.fg_color, ta.sma(grad1, 7)), "Trend Fill", display = c ? display.all : display.none)

// Trend signals
plotshape(ta.crossover(trend, 0), "Bullish Trend", shape.labelup, location.belowbar, upColor, text = "▲", textcolor = chart.fg_color)
plotshape(ta.crossunder(trend, 0), "Bearish Trend", shape.labeldown, location.abovebar, downColor, text = "▼", textcolor = chart.fg_color)

// TP signals
plotchar(ta.crossover(src, lower1), "Short TP", "X", location.belowbar, upColor, size = size.tiny)
plotchar(ta.crossunder(src, upper1), "Long TP", "X", location.abovebar, downColor, size = size.tiny)

// ============================================================================
// DRAW GAUGE
// ============================================================================
for i = 1 to tc
    color_ = chart.fg_color
    color = color.from_gradient(i, 1, tc, src > basis ? upColor : downColor, color_)
    printTable("", 1, i, color, ">", 1, math.round(y * tc), #ffffff00)

// ============================================================================
// ALERTS
// ============================================================================
alertcondition(ta.cross(trend, 0), "Universal Trend Shift", "Trend Changed Direction!")
alertcondition(ta.crossover(trend, 0), "Bullish Trend", "Bullish Trend Started!")
alertcondition(ta.crossunder(trend, 0), "Bearish Trend", "Bearish Trend Started!")
alertcondition(ta.crossover(src, lower1) or ta.crossunder(src, upper1), "Universal TP", "Take Profit Signal!")
alertcondition(ta.crossover(src, lower1), "Short TP", "Short Take Profit!")
alertcondition(ta.crossunder(src, upper1), "Long TP", "Long Take Profit!")

Overview

Trend Strength Signals Enhanced computes a simple moving average as basis and plots upper and lower bands using standard deviation. The region between bands fills with color. Bar color changes based on price position relative to bands. Bullish signals trigger on price crossing above basis. Bearish signals activate on price crossing below basis. Take-profit signals appear on extended bands with multiplier setting. A right-side gauge table visualizes strength level. Signals plot directly on the price chart.

Details

Published by

haydarkadioglu on GitHub

Code credit

AlgoAlpha, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, 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.

Settings

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

SettingTypeDefaultVariable
Enable Cloudbooltruec
Periodint20lenn
Standard Deviation Multiplier for TPfloat2.5mult
Gauge Sizeint25tc
Up Colorcolor#00ffbbupColor
Down Colorcolor#ff1100downColor
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
277 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 yesterday · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
219 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 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