Divergence Long/Short Signals

Divergence Long/Short Signals
Divergence Long/Short Signals is an overlay indicator that identifies regular bullish and bearish divergences between price and two momentum oscillators: the Commodity Channel Index (CCI) and the Relative Strength Index (RSI).
The indicator compares consecutive price pivots and evaluates oscillator readings at those same pivot bars. It classifies each qualifying divergence as Weak, Medium, or Strong according to whether CCI alone, both oscillators, or both oscillators plus additional volume conditions support the setup.
Its purpose is to make these different combinations visible directly on the price chart. It is not a trading strategy and does not calculate entries, exits, stop-loss levels, or profit targets.
How divergence detection works
The script identifies price swing lows and swing highs using configurable left-side and right-side pivot lengths.
A pivot low is evaluated against the immediately preceding confirmed pivot low. A pivot high is evaluated against the immediately preceding confirmed pivot high. The oscillator readings are taken from those price-pivot bars; the script does not independently detect and match oscillator pivots.
Bullish divergence occurs when:
The current price pivot low is lower than the previous price pivot low.
CCI, RSI, or both have a higher reading at the current pivot low than at the previous one.
Bearish divergence occurs when:
The current price pivot high is higher than the previous price pivot high.
CCI, RSI, or both have a lower reading at the current pivot high than at the previous one.
CCI divergence is required for every displayed signal. An RSI divergence without a corresponding CCI divergence does not produce a signal.
Only regular divergences are detected. Hidden divergences are not included.
Signal classification
Weak Long / Weak Short
A Weak signal appears when CCI confirms the relevant price divergence, but RSI does not.
Weak Long: price makes a lower pivot low while CCI makes a higher reading, without matching RSI divergence.
Weak Short: price makes a higher pivot high while CCI makes a lower reading, without matching RSI divergence.
Volume does not affect the Weak classification.
Medium Long / Medium Short
A Medium signal appears when both CCI and RSI confirm the divergence, but the complete volume condition required for a Strong signal is not satisfied.
Strong Long / Strong Short
A Strong signal requires divergence in both CCI and RSI, together with both of the following volume conditions:
Volume on the current price-pivot bar exceeds its volume simple moving average multiplied by the selected Volume Multiplier.
Volume on the current price-pivot bar exceeds volume on the previous price pivot of the same type.
For example, with the default multiplier of 1.2, pivot-bar volume must exceed 120% of its volume SMA and also exceed the volume of the preceding same-type pivot.
The volume comparison uses data from the pivot bar, not from the later bar on which the pivot becomes confirmed.
Weak, Medium, and Strong describe combinations of conditions. They are not measured probabilities, profitability ratings, or guarantees of a reversal.
Calculation inputs
The indicator uses:
RSI calculated from closing prices, with a default length of 14.
CCI calculated from HLC3, the average of high, low, and close, with a default length of 20.
A simple moving average of volume, with a default length of 20.
Price pivots with default settings of 5 left bars and 5 right bars.
There is no additional requirement for RSI or CCI to cross an overbought or oversold threshold. Divergence detection is based on comparisons between readings at consecutive price pivots.
Chart display
Long labels appear below qualifying price pivot lows:
Lime: Weak Long.
Teal: Medium Long.
Green: Strong Long.
Short labels appear above qualifying price pivot highs:
Orange: Weak Short.
Red: Medium Short.
Maroon: Strong Short.
The display settings allow each signal category to be shown or hidden independently.
Optional pivot marks display small circles at detected pivot lows and highs, including pivots that do not generate a divergence signal. These marks help show which price swings the indicator uses for its comparisons.
The indicator works independently and does not require another indicator on the chart.
Signal timing and historical placement
Pivots require right-side bars before they can be confirmed. As a result, signals are detected after the price-pivot bar, not at the moment that pivot first forms.
With the default Right Bars setting of 5, a qualifying pivot can be confirmed five chart bars after the pivot bar. The signal label is then placed back on the original pivot bar to identify the swing being evaluated.
This historical placement must not be interpreted as a signal that was available on the pivot bar itself. Alerts relate to the later detection bar.
The script does not explicitly restrict its calculations to closed bars. During an open realtime detection bar, a provisional pivot and its associated signal can change or disappear before the bar closes. For close-confirmed notifications, configure alerts to trigger Once Per Bar Close.
Settings
RSI Length: controls the RSI calculation period.
CCI Length: controls the CCI calculation period.
Pivot Left Bars: sets the number of bars required to the left of a price pivot.
Pivot Right Bars: sets the number of bars required to the right of a price pivot and therefore the confirmation delay.
Volume SMA Length: controls the averaging period used for the volume comparison.
Volume Multiplier: sets the volume threshold required for Strong signals.
Show Weak / Medium / Strong Signals: controls visibility of each label category.
Show Pivot Marks: enables or disables the optional price-pivot circles.
Longer pivot settings require a swing to satisfy comparisons across more surrounding bars. Increasing Right Bars also increases the signal-confirmation delay.
Alerts
Six separate alert conditions are available:
Weak Long.
Medium Long.
Strong Long.
Weak Short.
Medium Short.
Strong Short.
The label-visibility settings do not disable the underlying alert conditions. Hiding a signal category only hides its chart labels.
Intended use and limitations
Use the labels to identify price swings where price movement and oscillator momentum disagree, and to distinguish CCI-only divergence from dual-oscillator divergence with or without the specified volume conditions.
A Long label identifies bullish divergence, not an automatic buy instruction. A Short label identifies bearish divergence, not an automatic sell instruction.
The script does not apply a trend filter, assess support or resistance, or manage trade risk. It also does not impose a maximum distance between the two compared pivots.
Strong classification depends on the chart symbol’s available volume data. If the required volume comparisons cannot be satisfied, a dual-oscillator divergence will not receive the Strong classification.
The indicator provides analytical signals only. It does not include backtested performance statistics or guarantee future results.
Divergence Long/Short Signals is an overlay indicator that identifies regular bullish and bearish divergences between price and two momentum oscillators: the Commodity Channel Index (CCI) and the Relative Strength Index (RSI).
The indicator compares consecutive price pivots and evaluates oscillator readings at those same pivot bars. It classifies each qualifying divergence as Weak, Medium, or Strong according to whether CCI alone, both oscillators, or both oscillators plus additional volume conditions support the setup.
Its purpose is to make these different combinations visible directly on the price chart. It is not a trading strategy and does not calculate entries, exits, stop-loss levels, or profit targets.
How divergence detection works
The script identifies price swing lows and swing highs using configurable left-side and right-side pivot lengths.
A pivot low is evaluated against the immediately preceding confirmed pivot low. A pivot high is evaluated against the immediately preceding confirmed pivot high. The oscillator readings are taken from those price-pivot bars; the script does not independently detect and match oscillator pivots.
Bullish divergence occurs when:
The current price pivot low is lower than the previous price pivot low.
CCI, RSI, or both have a higher reading at the current pivot low than at the previous one.
Bearish divergence occurs when:
The current price pivot high is higher than the previous price pivot high.
CCI, RSI, or both have a lower reading at the current pivot high than at the previous one.
CCI divergence is required for every displayed signal. An RSI divergence without a corresponding CCI divergence does not produce a signal.
Only regular divergences are detected. Hidden divergences are not included.
Signal classification
Weak Long / Weak Short
A Weak signal appears when CCI confirms the relevant price divergence, but RSI does not.
Weak Long: price makes a lower pivot low while CCI makes a higher reading, without matching RSI divergence.
Weak Short: price makes a higher pivot high while CCI makes a lower reading, without matching RSI divergence.
Volume does not affect the Weak classification.
Medium Long / Medium Short
A Medium signal appears when both CCI and RSI confirm the divergence, but the complete volume condition required for a Strong signal is not satisfied.
Strong Long / Strong Short
A Strong signal requires divergence in both CCI and RSI, together with both of the following volume conditions:
Volume on the current price-pivot bar exceeds its volume simple moving average multiplied by the selected Volume Multiplier.
Volume on the current price-pivot bar exceeds volume on the previous price pivot of the same type.
For example, with the default multiplier of 1.2, pivot-bar volume must exceed 120% of its volume SMA and also exceed the volume of the preceding same-type pivot.
The volume comparison uses data from the pivot bar, not from the later bar on which the pivot becomes confirmed.
Weak, Medium, and Strong describe combinations of conditions. They are not measured probabilities, profitability ratings, or guarantees of a reversal.
Calculation inputs
The indicator uses:
RSI calculated from closing prices, with a default length of 14.
CCI calculated from HLC3, the average of high, low, and close, with a default length of 20.
A simple moving average of volume, with a default length of 20.
Price pivots with default settings of 5 left bars and 5 right bars.
There is no additional requirement for RSI or CCI to cross an overbought or oversold threshold. Divergence detection is based on comparisons between readings at consecutive price pivots.
Chart display
Long labels appear below qualifying price pivot lows:
Lime: Weak Long.
Teal: Medium Long.
Green: Strong Long.
Short labels appear above qualifying price pivot highs:
Orange: Weak Short.
Red: Medium Short.
Maroon: Strong Short.
The display settings allow each signal category to be shown or hidden independently.
Optional pivot marks display small circles at detected pivot lows and highs, including pivots that do not generate a divergence signal. These marks help show which price swings the indicator uses for its comparisons.
The indicator works independently and does not require another indicator on the chart.
Signal timing and historical placement
Pivots require right-side bars before they can be confirmed. As a result, signals are detected after the price-pivot bar, not at the moment that pivot first forms.
With the default Right Bars setting of 5, a qualifying pivot can be confirmed five chart bars after the pivot bar. The signal label is then placed back on the original pivot bar to identify the swing being evaluated.
This historical placement must not be interpreted as a signal that was available on the pivot bar itself. Alerts relate to the later detection bar.
The script does not explicitly restrict its calculations to closed bars. During an open realtime detection bar, a provisional pivot and its associated signal can change or disappear before the bar closes. For close-confirmed notifications, configure alerts to trigger Once Per Bar Close.
Settings
RSI Length: controls the RSI calculation period.
CCI Length: controls the CCI calculation period.
Pivot Left Bars: sets the number of bars required to the left of a price pivot.
Pivot Right Bars: sets the number of bars required to the right of a price pivot and therefore the confirmation delay.
Volume SMA Length: controls the averaging period used for the volume comparison.
Volume Multiplier: sets the volume threshold required for Strong signals.
Show Weak / Medium / Strong Signals: controls visibility of each label category.
Show Pivot Marks: enables or disables the optional price-pivot circles.
Longer pivot settings require a swing to satisfy comparisons across more surrounding bars. Increasing Right Bars also increases the signal-confirmation delay.
Alerts
Six separate alert conditions are available:
Weak Long.
Medium Long.
Strong Long.
Weak Short.
Medium Short.
Strong Short.
The label-visibility settings do not disable the underlying alert conditions. Hiding a signal category only hides its chart labels.
Intended use and limitations
Use the labels to identify price swings where price movement and oscillator momentum disagree, and to distinguish CCI-only divergence from dual-oscillator divergence with or without the specified volume conditions.
A Long label identifies bullish divergence, not an automatic buy instruction. A Short label identifies bearish divergence, not an automatic sell instruction.
The script does not apply a trend filter, assess support or resistance, or manage trade risk. It also does not impose a maximum distance between the two compared pivots.
Strong classification depends on the chart symbol’s available volume data. If the required volume comparisons cannot be satisfied, a dual-oscillator divergence will not receive the Strong classification.
The indicator provides analytical signals only. It does not include backtested performance statistics or guarantee future results.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.