Algo Divergences


Visualize divergences on the RSI (or any oscillator) with the beautiful Algo Divergences indicator. These divergences can also be used as part of a strategy within the StratBuilder. Everything is customizable, from the colors to the plots to the lookback to identify divergences. Comes FREE with the StratBuilder.
But first, we need to define some terms.


What is RSI?

The RSI is an indicator that stands for ‘Relative Strength Index’.


What are Divergences?

A divergence occurs when price moves in the opposite direction of the oscillator (RSI, in this case). In other words, a chart might display a change in momentum before a corresponding change in price.
The Algo Divergences indicator can visually display all 4 types of divergences. The StratBuilder is using the same divergences that are displayed in the Algo Divergences indicator.

The 4 types of divergences are:
Regular Bullish Divergence - Lower low on price action and higher low on oscillator
Regular Bearish Divergence - Higher high on price action and lower high on oscillator
Hidden Bullish Divergence - Higher low on price action and lower low on oscillator
Hidden Bearish Divergence - Lower high on price action and higher high on oscillator

By default, the colors for each divergences are:
Regular Bullish Divergence - Green
Regular Bearish Divergence - Red
Hidden Bullish Divergence - Blue
Hidden Bearish Divergence - Yellow


How are Pivot Highs/Lows Calculated?

Algo Divergences attempts to identify local highs/lows as pivots, not swing highs/lows. So the calculation is pretty complex but basically:
For Pivot Highs - When a potential high is identified, there needs to be a candle that closes below the low of that candle or the low of the next red candle (if it comes immediately after the high) to confirm that high as a pivot high.
For Pivot Lows - When a potential low is identified, there needs to be a candle that closes above the high of that candle or the high of the next green candle (if it comes immediately after the low) to confirm that low as a pivot low.

A new divergence can only appear when a new pivot high/low has been confirmed. This is because whenever a pivot high/low is confirmed, the indicator looks back 22 bars (or the number specified in the settings for 'Divergence Bars Lookback') and attempts to identify a divergence.

This also means that divergences are not confirmed on the same bar they occur. In fact, divergences can be identified up to 7 bars in the future.

The small triangles represent the pivot highs/lows.


‘Use External Oscillator For Divergences (not RSI)’ and ‘External Oscillator:’ Settings

This setting is false by default. The default oscillator for divergences is the RSI. If you would like to use a different oscillator, you can turn this on by clicking the checkbox, and then selecting your preferred oscillator in the dropdown below it labeled ‘External Oscillator’ (oscillator must be on your chart to select it).

Note: The ‘External Oscillator:’ dropdown input will only matter if the ‘Use External Oscillator For Divergences (not RSI)’ setting is checked on.


‘Divergence Bars Lookback’

The maximum amount of bars a pivot high/low can be from the other pivot high/low that it is drawing divergence from.
For example, if your ‘Divergence Bars Lookback’ is 22, and there is regular bullish divergence between two pivot highs but they are 23 bars apart, then that divergence will not count.


‘RSI Data Source’ and ‘RSI Length’

The default for ‘RSI Data Source’ is ‘close’. This means that the RSI is calculating its values based on the closing price of the current chart.
The default for ‘RSI Length’ is 14, this is the number of bars the RSI can look back into the chart to make its calculation.