Indicator · Pine Script v6 · Own pane

Squeeze Momentum [trugurpala]

by trugurpala

This indicator computes a momentum value via linear regression on the difference between close price and a mid-value average that blends highest-lowest range and high-close average over the Keltner Channel length.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code49
Settings4inputs
LicenceMIT
Last update2 months ago3 Aug 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

49 lines of Pine Script v6 from examples/indicators/17_squeeze_momentum.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

17_squeeze_momentum.pine
//@version=6
// Squeeze Momentum (LazyBear inspired) — Pine Script v6
// github.com/trugurpala/pinescriptv6 — Author: Ugur Pala
indicator("Squeeze Momentum [trugurpala]", overlay=false)

// ── Inputs ───────────────────────────────────────────────────────────────────
int   bbLen    = input.int(20,   "BB Length",   minval=1)
float bbMult   = input.float(2.0, "BB Mult",    step=0.1)
int   kcLen    = input.int(20,   "KC Length",   minval=1)
float kcMult   = input.float(1.5, "KC Mult",    step=0.1)

// ── Calculations ─────────────────────────────────────────────────────────────
// Bollinger Bands
[bbUpper, bbBasis, bbLower] = ta.bb(close, bbLen, bbMult)

// Keltner Channels
float kcMa    = ta.ema(close, kcLen)
float kcRange = ta.atr(kcLen) * kcMult
float kcUpper = kcMa + kcRange
float kcLower = kcMa - kcRange

// Squeeze: BB içinde mi KC?
bool sqzOn  = bbLower > kcLower and bbUpper < kcUpper
bool sqzOff = bbLower < kcLower and bbUpper > kcUpper
bool noSqz  = not sqzOn and not sqzOff

// Momentum — math.avg() v6'da yok, (a+b)/2 kullan
float highLow   = (ta.highest(kcLen) + ta.lowest(kcLen)) / 2
float highClose = (ta.highest(kcLen) + close) / 2
float midVal    = (highLow + highClose) / 2
float mom       = ta.linreg(close - midVal, kcLen, 0)

// ── Colors ───────────────────────────────────────────────────────────────────
color momColor = mom > 0
    ? (mom > mom[1] ? color.new(color.green,  0) : color.new(color.green, 50))
    : (mom < mom[1] ? color.new(color.red,    0) : color.new(color.red,   50))

// ── Visuals ──────────────────────────────────────────────────────────────────
plot(mom, "Momentum", momColor, style=plot.style_histogram, linewidth=4)
hline(0, "Zero", color.new(color.gray, 50))

plotshape(sqzOn,  "Squeeze On",  shape.circle, location.bottom,
    color.new(color.red,   20), size=size.tiny, title="Sqz On")
plotshape(sqzOff, "Squeeze Off", shape.circle, location.bottom,
    color.new(color.green, 20), size=size.tiny, title="Sqz Off")
plotshape(noSqz,  "No Squeeze",  shape.circle, location.bottom,
    color.new(color.gray,  40), size=size.tiny, title="No Sqz")

alertcondition(sqzOff and sqzOn[1], "Squeeze Fire", "Squeeze Released — {{ticker}}")

Overview

Squeeze Momentum [trugurpala] overlays Bollinger Bands and Keltner Channels to identify squeezes when price bands compress. The script renders a momentum histogram in a separate pane with green or red coloring based on slope changes, plus plot shapes for Squeeze On (red), Squeeze Off (green) and no-squeeze (gray) events. Inputs control Bollinger and Keltner lengths and multipliers. Alerts fire on squeeze release. The tool draws purely on the price chart in a dedicated pane and does not repaint.

Details

Published by

trugurpala on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volatility & bands, Moving averages

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

aialgorithmic-tradingclaude-codecodexcoding-agentsgithub-copilotopen-sourcepine-scriptpine-script-v6technical-analysis

Settings

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

SettingTypeDefaultVariable
BB Lengthint20bbLen
BB Multfloat2.0bbMult
KC Lengthint20kcLen
KC Multfloat1.5kcMult
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

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

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

This indicator plots a relative strength index in a separate pane. It calculates RSI from the average of the previous ten opens rather than the current bar, so that source does not change during the live candle. A moving average of the RSI is plotted and can b

Indicator v5 Oscillators & momentumMoving averages
Updated 2 years ago · None stated GitHub repository of No Repaint - Relative Strength Index

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