Indicator - Divergence Index
Function - PeakDivergence
Function - TroughDivergence
Category: Indicator > Miscellaneous
Divergence between market prices and an indicator applied to those prices can provide a strong signal of an impending price reversal. For example, when prices make new highs but the indicator does not, an important market top may be forming.
This study is a way to measure divergence between price highs and an indicator to predict the strength of a new market top. This method could also be used to measure the divergence between price lows and an indicator to predict the strength of a new market bottom. In addition, instead of measuring the divergence between prices and an indicator, it could be used to measure the divergence between any two values - two different prices or even two different indicators.
This study is calculating according to these formulas:
Hc = High at the current peak.
Hp = High at the previous peak
Hh = Highest high from the previous to the current peak
Hl = Lowest high from the previous to the current peak
Ic = Indicator value at the current peak
Ip = Indicator value at the previous peak
Ih = Highest indicator value from the previous to the current peak
Il = Lowest indicator value from the previous to the current peak
Ic = Indicator value at the current trough
Ip = Indicator value at the previous trough
Ih = Highest indicator value from the previous to the current trough
Il = Lowest indicator value from the previous to the current trough
Lc = Low at the current trough.
Lp = Low at the previous trough
Lh = Highest low from the previous to the current trough
Ll = Lowest low from the previous to the current trough
When the market fails to make a new high after a rally, the divergence between the peak just formed and the previous peak can help determine if the new peak is likely to become significant. Divergence can be either positive or negative. The more positive the divergence is, the more likely a reversal is about to take place.
Although a positive divergence is a strong signal of price reversal, an even stronger signal occurs when the high at the current peak is higher than the high at the previous peak (Hc > Hp ) and the indicator value at the current peak is lower than the indicator value at the previous peak (Ic < Ip ). This is the classic divergence most often illustrated in technical analysis literature.
A negative divergence often indicates that a false peak is occurring and the market will soon turn around and continue to rally.
IF CHECKALERT THEN BEGIN
IF PLOT1 CROSSES ABOVE PLOT2 OR PLOT1 CROSSES BELOW PLOT2