Indicator · Pine Script v6 · On the chart

Momentum Swing

by rubbermetal· code credited to claygrace74

Momentum Swing is an indicator, not a strategy, that marks Long and Short signals when a MACD cross coincides with an oversold or overbought RSI reading and ADX above 25.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code83
Settings10inputs
LicenceMPL-2.0
Last update4 months ago10 Jun 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

83 lines of Pine Script v6 from Momentum Swing Strategy.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Momentum Swing Strategy.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © claygrace74

//@version=6
indicator("Momentum Swing", shorttitle="MomSwing", overlay=true)

// ==================== Settings ====================
var mom_group = "Momentum Settings"
fast_length = input.int(5, "Fast EMA Length", minval=1, group=mom_group)
slow_length = input.int(12, "Slow EMA Length", minval=1, group=mom_group)
rsi_length  = input.int(14, "RSI Length", minval=1, group=mom_group)
adxPeriod   = input.int(14, "ADX Period", minval=1, group=mom_group)
atrLength   = input.int(14, "ATR Length", minval=1, group=mom_group)

var vol_group = "Volume Settings"
high_volume_multiplier = input.float(2.0, "High Volume Multiplier", minval=1, group=vol_group)

var disp_group = "Display Settings"
i_showSignals = input.bool(true, "Show Entry Signals", group=disp_group)
i_showVolBars = input.bool(true, "Show Volume-Colored Bars", group=disp_group)
i_showSLlines = input.bool(true, "Show ATR Stop Loss Lines", group=disp_group)
atr_sl_mult   = input.float(2.0, "ATR Stop Loss Multiplier", minval=0.5, step=0.5, group=disp_group)

// ==================================================================================
// Core Calculations
// ==================================================================================
ema_fast = ta.ema(close, fast_length)
ema_slow = ta.ema(close, slow_length)
macd = ema_fast - ema_slow
macd_signal = ta.ema(macd, 9)
rsi = ta.rsi(close, rsi_length)
avg_volume = ta.sma(volume, 50)
atr = ta.atr(atrLength)

[diPlus, diMinus, adxValue] = ta.dmi(adxPeriod, 14)

// High volume detection
high_vol_up   = close > open and volume > high_volume_multiplier * avg_volume
high_vol_down = close < open and volume > high_volume_multiplier * avg_volume

// Entry signals — MACD cross + RSI extreme + strong trend (ADX > 25)
long_signal  = ta.crossover(macd, macd_signal) and rsi < 30 and adxValue > 25
short_signal = ta.crossunder(macd, macd_signal) and rsi > 70 and adxValue > 25

// ATR-based stop levels from signal bars
var float longSL = na
var float shortSL = na
if long_signal
    longSL := close - atr * atr_sl_mult
if short_signal
    shortSL := close + atr * atr_sl_mult

// ==================================================================================
// Plots
// ==================================================================================

// EMA lines
plot(ema_fast, "Fast EMA", color=color.new(color.blue, 0), linewidth=1)
plot(ema_slow, "Slow EMA", color=color.new(color.yellow, 0), linewidth=1)

// Volume-colored bars
candle_color = close > open ? color.new(color.green, 30) : color.new(color.red, 30)
high_vol_color = high_vol_up ? color.new(color.blue, 0) : high_vol_down ? color.new(color.fuchsia, 0) : candle_color
barcolor(i_showVolBars ? high_vol_color : na)

// Entry signals
plotshape(i_showSignals and long_signal,  style=shape.triangleup,   location=location.belowbar, color=color.green, text="Long",  textcolor=color.green, size=size.small, title="Long Signal")
plotshape(i_showSignals and short_signal, style=shape.triangledown, location=location.abovebar, color=color.red,   text="Short", textcolor=color.red,   size=size.small, title="Short Signal")

// ATR stop loss lines
plot(i_showSLlines and not na(longSL) and close > longSL ? longSL : na, "Long SL", color=color.new(color.orange, 40), style=plot.style_linebr, linewidth=1)
plot(i_showSLlines and not na(shortSL) and close < shortSL ? shortSL : na, "Short SL", color=color.new(color.orange, 40), style=plot.style_linebr, linewidth=1)

// Trend background when ADX confirms
bgcolor(adxValue > 25 and diPlus > diMinus ? color.new(color.green, 95) : adxValue > 25 and diMinus > diPlus ? color.new(color.red, 95) : na, title="ADX Trend BG")

// ==================================================================================
// Alert Conditions
// ==================================================================================
alertcondition(long_signal,   "Momentum Long Signal",  "MACD cross up + RSI oversold + ADX trending")
alertcondition(short_signal,  "Momentum Short Signal", "MACD cross down + RSI overbought + ADX trending")
alertcondition(high_vol_up,   "High Volume Bull Bar",  "Bullish candle with volume above multiplier threshold")
alertcondition(high_vol_down, "High Volume Bear Bar",  "Bearish candle with volume above multiplier threshold")

Overview

Momentum Swing plots fast and slow EMAs, colors bars when volume exceeds a multiple of its 50-bar average, and draws ATR-based stop loss reference lines from the latest signal. It places no orders. It draws on the price chart.

Details

Published by

rubbermetal on GitHub

Code credit

claygrace74, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Oscillators & momentum, Trend, Volume

Markets

Any symbol

Timeframes

H4 and above

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
Fast EMA Lengthint5fast_length
Slow EMA Lengthint12slow_length
RSI Lengthint14rsi_length
ADX Periodint14adxPeriod
ATR Lengthint14atrLength
High Volume Multiplierfloat2.0high_volume_multiplier
Show Entry Signalsbooltruei_showSignals
Show Volume-Colored Barsbooltruei_showVolBars
Show ATR Stop Loss Linesbooltruei_showSLlines
ATR Stop Loss Multiplierfloat2.0atr_sl_mult
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

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

Aroon-based Strategy

by capissimo
114 stars

This indicator overlay generates buy and sell signals based on Aroon extreme levels combined with optional volume or volatility filters. It calculates Aroon Up and Aroon Down lines using localized high and low lookbacks, generating trade entries when Aroon rea

Indicator v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Aroon-based Strategy
92 stars

This indicator plots a volume-weighted average price of the typical price on the chart and colors that line by ADX strength. It draws a standard-deviation envelope around VWAP and tints the fill green when plus DI leads and red when minus DI leads. Triangle ma

Indicator v5 TrendOscillators & momentum
Updated 2 months ago · Custom licence GitHub repository of Moon Dev VWAP x ADX Explosion

Signal Strategy 15m

by tripolskypetr
72 stars

This indicator generates trend-following trade signals on the price chart by combining moving average crossovers with multi-factor filters. It triggers entry alerts when fast and slow EMAs cross in the direction of a baseline trend EMA, confirmed by non-extrem

Indicator v5 TrendMoving averages
Updated 4 days ago · MIT GitHub repository of Signal Strategy 15m
46 stars

This overlay indicator plots a SuperTrend using a 10-period ATR with a multiplier of 3, drawing up and down stop lines and a faint trend fill on the price chart. It compares a 9-period EMA with an 18-period EMA and a 12/26/9 MACD against its signal, and it req

Indicator v5 TrendOscillators & momentum
Updated 3 years ago · None stated GitHub repository of SuperTrend + MACD + EMA

Bte Acc

by f-cksociety
11 stars

Bte Acc is a chart indicator form of the PineCoders Backtesting and Trading Engine. It seeks an entry trigger from a main or alternate entry method, then checks trade direction, filters, date range, ATR readiness, and remaining capital before filling on the ne

Indicator v5 TrendOscillators & momentum Repaints
Updated 4 years ago · MPL-2.0 GitHub repository of Bte Acc

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