MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points.
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 strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
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
MACD + Divergences [Alorse] filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure trades align with the macro trend. Position exits are managed using percentage-based or ATR-based stop losses along with profit targets. The script plots the MACD line, signal line, histogram, and divergence lines in a separate pane. Note that divergence lines rely on pivot lookback evaluation, causing historical signals to appear confirmed after a set bar delay.
MACD oscillator with custom EMA or SMA smoothing options
Automated pivot-based divergence detection
Dual EMA trend direction filters
ATR or percentage-based stop loss and take profit settings
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Version
string
txtVer
version
Source
source
close
src
Length Fast
int
12
fast_length
Slow
int
26
slow_length
Signal Smoothing
int
9
signal_length
Oscillator
string
EMA
sma_source
Signal Line
string
EMA
sma_signal
MACD Line
color
#2962FF
col_macd
Signal Line
color
#FF6D00
col_signal
Show Signals&MACD Cross
bool
true
showCross
Above Grow
color
#00796b
col_grow_above
Fall
color
#26a69a
col_fall_above
Show all 31 settings
Setting
Type
Default
Variable
Below Grow
color
#ef5350
col_grow_below
Fall
color
#b71c1c
col_fall_below
Don't touch the zero line?
bool
true
donttouchzero
Pivot Lookback Right
int
2
lbR
Pivot Lookback Left
int
7
lbL
Max of Lookback Range
int
200
rangeUpper
Min of Lookback Range
int
10
rangeLower
Plot Bullish
bool
true
plotBull
Plot Bearish
bool
true
plotBear
EMA 1
int
150
maA
EMA 2
int
600
maB
Bars back
int
10
barsBack
Take profit factor
float
1.5
tpFactor
╔══════ Enable ══════╗
bool
true
useSL
Based on
string
Percent
SLbased
ATR Mult
float
7.0
multiATR
Length
int
14
lengthATR
Percent
float
7
SLPercent
Show SL
bool
true
plotSL
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.
This strategy executes long positions by combining a 200-period EMA trend filter, Stochastic RSI oversold crosses, and Williams Alligator retracements, supplemented by RSI divergence detection. It triggers long entries when the price trades above the 200 EMA w
This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr
An ADX-based trend-following strategy that enters long positions when the positive directional indicator (DI+) crosses above the Average Directional Index (ADX) while ADX remains below a preset threshold and a fast EMA is above a slow EMA. It allows adding to
This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta
This strategy implements Bill Williams' Awesome Oscillator (AO) calculated as the difference between two simple moving averages of the median price. It generates long and short entries using three classic signal triggers: zero-line crossovers, twin peaks diver
This strategy evaluates the dynamic relationship between price and a chosen moving average across six diagnostic dimensions: trend, respect, extension, compression, acceleration, and exhaustion. It plots a normalized relationship oscillator bounded between -10