CCI Divergence Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

CCI swings far and fast. That makes divergence easy to spot by eye, and easy to over-read. The CCI divergence indicator uses a rule instead. It confirms price pivots with five bars on each side and pairs each with an earlier pivot five to sixty bars back. It only counts divergence when CCI moved at least eight points the other way.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Separate window (levels 100 / 0 / -100)
Plots 3: CCI, Bullish Divergence, Bearish Divergence
Alerts popup, push notification, email, sound
Inputs 15

What draws where

A CCI line, trendlines and two marks in a pane.

`CCI` traces sandy brown at width 2.

`Bullish Divergence` prints lime with arrow 233.

`Bearish Divergence` prints red with arrow 234.

`BullLineColor` `clrLime` joins bullish pivots on the CCI.

Guides sit at +100, 0 and -100.

  • CCI: line, sandy brown, width 2
  • Bullish Divergence: arrow, lime, width 2, arrow code 233
  • Bearish Divergence: arrow, red, width 2, arrow code 234
cci divergence indicator: CCI pane with a divergence trendline, EURUSD H1.
CCI pane with a divergence trendline, EURUSD H1.

Under the hood

Cci

`CciPeriod` `14` reads the typical price. A reading past 100 either way is stretched.

Pivots

`PivotLookback` `5` bars on each side confirm a price pivot. Its partner sits between `DivergenceMinBars` `5` and `DivergenceMaxBars` `60` bars back.

Divergence

A lower price low with CCI at least `DivergenceMinDeltaCci` `8.0` points higher prints a bullish mark. `ShowTrendlines` joins the two CCI points.

Interpreting what you see

A lime line rising on CCI under falling lows is bullish.

A red line falling on CCI over rising highs is bearish.

Marks sit on the CCI at the newer pivot.

Marks arrive five bars after the pivot.

Small CCI differences are ignored.

Warm-up needs about twenty bars.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

A confirmed divergence sends one message once its pivot locks in. `EnableAlerts` is the master switch; only the popup is enabled from the start.

Every Cci Divergence Indicator input

Core settings

Setting What it does Default
CciPeriod CCI period. CCI length, `14`. 14
PivotLookback bars on each side of a pivot. Bars on each side of a pivot, `5`. 5
DivergenceMinBars min distance between pivots. Nearest partner pivot, `5`. 5
DivergenceMinDeltaCci min CCI delta to count as divergence. Smallest CCI gap that counts, `8.0`. 8.0

Display settings

Setting What it does Default
DivergenceMaxBars max distance between pivots. Farthest partner pivot, `60`. 60
ShowTrendlines draw colored CCI trendlines. Join the CCI points, `true`. on
BullLineColor Bullish line colour, `clrLime`. lime
BearLineColor Bearish line colour, `clrRed`. red
LineWidth Trendline width, `2`. 2

Alert settings

Setting What it does Default
EnableAlerts Master alert switch, `true`. on
EnablePopup (see inputs panel) on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile (see inputs panel) alert.wav
cci divergence indicator: Inputs panel, pivot and divergence settings together.
Inputs panel, pivot and divergence settings together.

Suitable charts

CCI divergence between five-bar pivots is a slow, selective signal. EURUSD H1 is the reference chart, with a divergence every few days. On M15 they come daily. On D1 each one deserves a proper look.

Limits worth knowing

Divergence can repeat through a strong trend.

Each mark is five bars late.

CCI has no fixed top or bottom.

Nothing but the popup is on by default.

Copy the compiled Cci Divergence Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the Cci Divergence Indicator for MT4 and MT5

The zip holds the compiled Cci Divergence Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What does DivergenceMinDeltaCci 8.0 filter?

Divergences where CCI barely differs between the two pivots. The CCI must move at least eight points against price, so tiny wiggles in the line do not produce marks.

How far apart can Bullish Divergence pivots be?

Between five and sixty bars, set by `DivergenceMinBars` and `DivergenceMaxBars`. Closer pivots sit too near to compare, and farther ones belong to another move entirely.

What do the ShowTrendlines lines connect?

The CCI values at the two pivots that formed the divergence. A lime line rising while price fell makes the bullish case visible at a glance.

Why does PivotLookback 5 delay each mark?

A price pivot needs five closed bars on its right. The divergence test only runs on confirmed pivots, so each mark appears five bars after the turn.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Cci Divergence Indicator as one input. Always backtest before trading live.

Category: this is part of our Oscillators collection. Also, truly, browse more Oscillators for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment