The Complete Trendline + MACD Divergence System identifies swing high and low pivots to detect MACD divergences and plot support or resistance trendlines directly on the price chart.
1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.
Overview
Complete Trendline + MACD Divergence System calculates MACD values, tracks price extremes over customizable lookback periods, and displays visual divergence markers alongside suggested stop-loss reference levels. Key inputs allow users to adjust MACD parameters, swing detection sensitivity, lookback distances, and risk buffer percentages. Divergence signals and trendlines appear retrospectively once pivot points are confirmed after the designated swing period.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
MACD Fast Length
int
12
macdFastLength
MACD Slow Length
int
26
macdSlowLength
MACD Signal Length
int
9
macdSignalLength
Swing Detection Period
int
5
swingPeriod
Trendline Extension Length
int
50
trendlineLength
Divergence Lookback Period
int
40
divergenceLookback
Show Divergences
bool
true
showDivergences
Divergence Line Width
int
2
divergenceLineWidth
Stop Loss Buffer %
float
0.2
stopLossBuffer
Stop Loss Lookback Bars
int
10
stopLossLookback
Show Trendlines
bool
true
showTrendlines
Show MACD Panel
bool
true
showMacdPanel
Show all 17 settings
Setting
Type
Default
Variable
Show Stop Loss Levels
bool
true
showStopLoss
Bullish Divergence Color
color
color.new(color.green, 0)
bullDivColor
Bearish Divergence Color
color
color.new(color.red, 0)
bearDivColor
Resistance Trendline Color
color
color.new(color.red, 30)
trendlineResColor
Support Trendline Color
color
color.new(color.blue, 30)
trendlineSupColor
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.
The GBPJPY System is a MACD divergence strategy for the GBPJPY pair. It calculates MACD on the 1-hour timeframe, RCI on the current bar, and EMA on the 4-hour timeframe to detect trend reversals and divergences. The script plots entry signals, stop loss, take
This indicator plots a momentum-based ZigZag on the price chart from a QQE calculation driven by a multi-timeframe RSI. It marks bullish and bearish ZigZag segments, optional divergence and convergence between price and that RSI, and an optional Supertrend lin
An all-in-one overlay tuned for the 6-hour chart, written in Pine v4. It bundles the Williams Alligator with fractal reversal setups, divergence detection, RSI, an ATR-ADX trend gauge at 8 hours, EMA crosses on 6-hour, 12-hour and daily frames, an Ichimoku clo
A large all-in-one overlay built for the 30-minute chart that bundles many tools in one script. It includes the Williams Alligator and fractal reversal setups, divergence detection, RSI, an ATR-ADX trend gauge, EMA crosses on 30-minute, 4-hour and daily frames
The indicator scores whether a counter-move against the dominant structure is maturing and whether price has started turning back. It plots a composite score in a separate pane from weighted context, correction maturity, and exhaustion, scaled by trigger and a
This indicator calculates key support and resistance levels by analyzing the first and second momentum derivatives of a Double Exponential Moving Average (DEMA). When the second derivative (momentum of momentum) crosses zero, it identifies local turning points