Strategy · Pine Script v4 · Own pane

MACD + Divergences [Alorse]

by Alorse

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points.

View on GitHub

Repaints

GitHub stars330on the repository
Pine versionv4older, still runs
Lines of code146
Settings31inputs
LicenceNone stated
Last update2 months ago25 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 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.

Details

Published by

Alorse on GitHub

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Divergence, Trend, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

pinescriptpinescript-indicatorspinescript-strategiestrading-strategiestradingviewtradingview-alerttradingview-strategy

Settings

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

SettingTypeDefaultVariable
VersionstringtxtVerversion
Sourcesourceclosesrc
Length   Fastint12fast_length
Slowint26slow_length
Signal Smoothingint9signal_length
OscillatorstringEMAsma_source
Signal LinestringEMAsma_signal
MACD Line  color#2962FFcol_macd
Signal Line  color#FF6D00col_signal
Show Signals&MACD CrossbooltrueshowCross
Above   Growcolor#00796bcol_grow_above
Fallcolor#26a69acol_fall_above
Show all 31 settings
SettingTypeDefaultVariable
Below Growcolor#ef5350col_grow_below
Fallcolor#b71c1ccol_fall_below
Don't touch the zero line?booltruedonttouchzero
Pivot Lookback Rightint2lbR
Pivot Lookback Leftint7lbL
Max of Lookback Rangeint200rangeUpper
Min of Lookback Rangeint10rangeLower
Plot BullishbooltrueplotBull
Plot BearishbooltrueplotBear
EMA 1int150maA
EMA 2int600maB
Bars backint10barsBack
Take profit factorfloat1.5tpFactor
╔══════   Enable   ══════╗booltrueuseSL
Based onstringPercentSLbased
ATR   Multfloat7.0multiATR
Lengthint14lengthATR
Percentfloat7SLPercent
Show SLbooltrueplotSL
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

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

Strategy v4 TrendOscillators & momentum
Updated 3 years ago · Apache-2.0 GitHub repository of 200 EMA + Alligator + Stochastic Long Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

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

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)

ADX Strategy

by hasnocool
106 stars

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

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of ADX Strategy

EMA Ribbon MACD

by iamrichardD
57 stars

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

Strategy v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon MACD

Awesome Oscillator - Eterna MCP

by EternaHybridExchange
9 stars

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

Strategy v5 Oscillators & momentumMoving averages
Updated 7 months ago · MIT GitHub repository of Awesome Oscillator - Eterna MCP

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

Strategy v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Market–Average Relationship Engine [WavesUnchained]

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers