Divergence Trading 6.0

Metatrader Indicator (MT4/MT5)

  • Overview

    Tricky to find and scarce in frequency, divergences are one of the most reliable and profitable trading scenarios. This indicator finds and scans for regular and hidden divergences automatically using your favourite oscillator.

    • Finds regular and hidden divergences
    • Supports many well known oscillators
    • Implements trading signals based on breakouts
    • Configurable oscillator parameters
    • Customizable colors and sizes
    • Filter divergences by size in bars
    • Implements performance statistics
    • Includes a multi-symbol and multi-timeframe scanner
    • It implements email/sound/visual alerts

    To offer a broad market perspective, the indicator can be loaded many times in the same chart using different oscillators, without interference. The indicator supports the following oscillators:

    • RSI
    • CCI
    • MACD
    • OSMA
    • Stochastic
    • Momentum
    • Awesome Oscillator
    • Accelerator Oscillator
    • Williams Percent Range
    • Relative Vigor Index
    • Money Flow Index
    • On Balance Volume

    Since divergences can expand quite a bit -especially in the forex market-, this indicator implements a twist: it waits for a donchian breakout to confirm the divergence before signaling the trade. The end result is an otherwise repainting indicator with a very reliable trading signal.

  • Input parameters
    Input parameters

    When loading the indicator or EA to any chart, you will be presented with a set of options as input parameters. Don't despair if you think they are too many, because parameters are grouped into self-explanatory blocks.

    Indicator to load
    Choose the oscillator to load to the chart.
    Divergence types
    Enable or disable divergence types: hidden, regular or both.
    Breakout period
    Breakout period in bars for the trading signals.
    Min divergence size in bars
    Minimum size in bars for a divergence to be displayed.
    Max divergence size in bars
    Maximum size in bars for a divergence to be displayed.
    Max. history bars
    Amount of bars to evaluate when the indicator is loaded.
    Indicator Settings
    Desired indicator settings for all the oscillators and indicators involved.
    Drawing Settings
    Choose colors and line sizes to draw divergences.
    Alert Events
    Enable or disable alerts for divergence and breakouts.
    Alerts
    Enable or disable alerts of all kinds.
  • ? FAQ
    Does the indicator repaint?
    Yes, the indicator must repaint to accomplish its function. Divergences can expand and therefore the indicator must redraw to follow the divergence as it expands. However, trading signals are based on breakouts and are mostly non-repainting.
    What kind of alerts does the indicator raise?
    The indicator will raise an alert when a divergence is detected, and another type of alert when a breakout happens confirming a divergence. It is recommended to trade on the breakout alone, because divergences can expand.
    What timeframe should I trade?
    Divergence signals tend to be more accurate on the longer time frames. You get less false signals. It is recommended to trade H4 and above.
    Can I load the indicator many times using different oscillators?
    Yes, you can. They won't interfere with each other.
    Can I call this indicator from an EA?
    No, the indicator does not have callable buffers. It only draws objects.
    Can I find divergences in many oscillators at the same time?
    Only if you load the indicator many times on the same chart.
    Does the indicator implement alerts?
    Yes, of all kinds.
  • </> Developers

    In order to build your expert advisor, you can read data from the indicator using the iCustom() function as exemplified below. The indicator has one extra buffer which only purpose is to store trading signals as constants: this is the only buffer you need to read from. Copy and paste the code below into your EA, and replace the indicator name of the iCustom() call with your own.

    //---- Define constants
    #define OP_REGULAR_BUY 0
    #define OP_REGULAR_SELL 1
    #define OP_HIDDEN_BUY 2
    #define OP_HIDDEN_SELL 3
    //---- Declare indicator type
    enum Indi_Type
    {
    RSI = 0,  // RSI
    CCI = 1,  // CCI
    MACD = 2,  // MACD
    OSMA = 3,  // OSMA (MACD Histogram)
    STOCH = 4,  // Stochastic
    AWESOME  = 5,  // Awesome Oscillator
    ACCELERATOR  = 6,  // Accelerator Oscillator
    MOMENTUM = 7,  // Momentum
    WILLIAMS  = 8,  // Williams Percent Range
    RVI = 9,  // Relative Vigor Index
    MFI = 10, // Money Flow Index
    OBV = 11, // On Balance Volume
    };
    //---- Declare divergence type
    enum Div_Type
    {
    Regular_And_Hidden  = 0,
    Regular = 1,
    Hidden  = 2,
    };
    //+-----------------------------------------------+
    //| Custom indicator iteration function
    //+-----------------------------------------------+
    int start()
    {
    // Assign indicator to use
    Indi_Type type = AWESOME;
    // Assign divergence type
    Div_Type div = Regular_And_Hidden;
    // Declare breakout period
    int breakout_period = 2;
    // Read divergence 
    double divergence  = iCustom(Symbol(), Period(), 
    "PZ_DivergenceTrading_LICENSE", 
    "--", type, div, breakout_period, 5, 1);
    // Read breakout
    double breakout  = iCustom(Symbol(), Period(), 
    "PZ_DivergenceTrading_LICENSE", 
    "--", type, div, breakout_period, 4, 1);
    // Actions on divergences (these can expand and repaint)
    if(divergence == OP_REGULAR_BUY)  { /* Your code for regular bullish divergence */ }
    if(divergence == OP_REGULAR_SELL) { /* Your code for regular bearish divergence  */ }
    if(divergence == OP_HIDDEN_BUY)      { /* Your code for hidden bullish divergence */ }
    if(divergence == OP_HIDDEN_BUY)      { /* Your code for hidden bearish divergence */ }
    // Actions on breakouts (these almost never repaint)
    if(breakout == OP_BUY)   { /* Your code for bullish breakout (blue arrow) */}
    if(breakout == OP_SELL)  { /* Your code for bearish breakout (red arrow) */}
    // Exit
    return(0);
    }
  • Comments

    Keep comments tidy and respectful. Avoid spam, offensive remarks, self-promotion and posting personal or payment information. The comment section is for discussion and questions only. Please note that we'll never solicit payments in the comments section.

Screenshots

Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader
Divergence Trading Indicator for Metatrader