OPEN-SOURCE SCRIPT

Divergence for Many Panel (D4MP+)

Updated
Divergence for Many Panel (D4MP+)

This Divergence for Many Panel indicator is built upon the realtme divergence drawing code originally authored by LonesomeTheBlue, now in the form of a panel indicator.

The available oscillators, hand picked for their ability to identify high quality divergences currently include:

- Ultimate Oscillator (UO)
- True Strength Index (TSI)
- Money Flow Index (MFI)
- Relative Strength Index (RSI)
- Stochastic RSI
- Time Segmented Volume (TSV)
- Cumulative Delta Volume (CDV)


Note: this list of available oscillators may be added to or altered at a later date.

The indicator includes the following features:

- Ability to select any of the above oscillators
- Optional divergence lines drawn directly onto the oscillator in realtime.
- Configurable alerts to notify you when divergences occur.
- Configurable pivot lookback periods to fine tune the divergences drawn in order to suit different trading styles and timeframes, including the ability to enable automatic adjustment of pivot period per chart timeframe.
- Background colouring option to indicate when the selected oscillator has crossed above or below its centerline.
- Alternate timeframe feature allows you to configure the oscillator to use data from a different timeframe than the chart it is loaded on.
- Oscillator name label, so you can clearly see which oscillator is selected, in the case you have multiple loaded onto a chart.
- Optional adjustable range bands.
- Automatic adjustment of line colours, centerlines and range band levels on a per oscillator basis by default.
- Ability to customise the colours of each of the oscillators.


What is the Ultimate Oscillator ( UO )?

“The Ultimate Oscillator indicator (UO) indicator is a technical analysis tool used to measure momentum across three varying timeframes. The problem with many momentum oscillators is that after a rapid advance or decline in price, they can form false divergence trading signals. For example, after a rapid rise in price, a bearish divergence signal may present itself, however price continues to rise. The ultimate Oscillator attempts to correct this by using multiple timeframes in its calculation as opposed to just one timeframe which is what is used in most other momentum oscillators.”

What is the True Strength Index ( TSI )?

"The true strength index (TSI) is a technical momentum oscillator used to identify trends and reversals. The indicator may be useful for determining overbought and oversold conditions, indicating potential trend direction changes via centerline or signal line crossovers, and warning of trend weakness through divergence."

What is the Money Flow Index ( MFI )?

“The Money Flow Index ( MFI ) is a technical oscillator that uses price and volume data for identifying overbought or oversold signals in an asset. It can also be used to spot divergences which warn of a trend change in price. The oscillator moves between 0 and 100. Unlike conventional oscillators such as the Relative Strength Index ( RSI ), the Money Flow Index incorporates both price and volume data, as opposed to just price. For this reason, some analysts call MFI the volume-weighted RSI .”

What is the Relative Strength Index ( RSI )?

"The relative strength index (RSI) is a momentum indicator used in technical analysis. RSI measures the speed and magnitude of a security's recent price changes to evaluate overvalued or undervalued conditions in the price of that security. The RSI can do more than point to overbought and oversold securities. It can also indicate securities that may be primed for a trend reversal or corrective pullback in price. It can signal when to buy and sell. Traditionally, an RSI reading of 70 or above indicates an overbought situation. A reading of 30 or below indicates an oversold condition. It is also commonly used to identify divergences."

What is the Stochastic RSI (StochRSI)?

"The Stochastic RSI (StochRSI) is an indicator used in technical analysis that ranges between zero and one (or zero and 100 on some charting platforms) and is created by applying the Stochastic oscillator formula to a set of relative strength index (RSI) values rather than to standard price data. Using RSI values within the Stochastic formula gives traders an idea of whether the current RSI value is overbought or oversold. The StochRSI oscillator was developed to take advantage of both momentum indicators in order to create a more sensitive indicator that is attuned to a specific security's historical performance rather than a generalized analysis of price change."

What Is Time Segmented Volume?

"Time segmented volume (TSV) is a technical analysis indicator developed by Worden Brothers Inc. that segments a stock's price and volume according to specific time intervals. The price and volume data is then compared to uncover periods of accumulation (buying) and distribution (selling)."

What is Cumulative Volume Delta ( CDV )?

"The CDV analyses the net buying at market price and net selling at market price. This means, that volume delta is measuring whether it is the buyers or sellers that are more aggressive in taking the current market price. It measures the degree of intent by buyers and sellers, which can be used to indicate who is more dominant. The CDV can be used to help identify possible trends and also divergences"

What are divergences?

Divergence is when the price of an asset is moving in the opposite direction of a technical indicator, such as an oscillator, or is moving contrary to other data. Divergence warns that the current price trend may be weakening, and in some cases may lead to the price changing direction.

There are 4 main types of divergence, which are split into 2 categories;
regular divergences and hidden divergences. Regular divergences indicate possible trend reversals, and hidden divergences indicate possible trend continuation.

Regular bullish divergence: An indication of a potential trend reversal, from the current downtrend, to an uptrend.
Regular bearish divergence: An indication of a potential trend reversal, from the current uptrend, to a downtrend.
Hidden bullish divergence: An indication of a potential uptrend continuation.
Hidden bearish divergence: An indication of a potential downtrend continuation.


Setting alerts.

With this indicator you can set alerts to notify you when any/all of the above types of divergences occur, on any chart timeframe you choose.


Configurable pivot periods.

You can adjust the default pivot periods to suit your prefered trading style and timeframe. If you like to trade a shorter time frame, lowering the default lookback values will make the divergences drawn more sensitive to short term price action.


How do traders use divergences in their trading?

A divergence is considered a leading indicator in technical analysis , meaning it has the ability to indicate a potential price move in the short term future.

Hidden bullish and hidden bearish divergences, which indicate a potential continuation of the current trend are sometimes considered a good place for traders to begin, since trend continuation occurs more frequently than reversals, or trend changes.

When trading regular bullish divergences and regular bearish divergences, which are indications of a trend reversal, the probability of it doing so may increase when these occur at a strong support or resistance level . A common mistake new traders make is to get into a regular divergence trade too early, assuming it will immediately reverse, but these can continue to form for some time before the trend eventually changes, by using forms of support or resistance as an added confluence, such as when price reaches a moving average, the success rate when trading these patterns may increase.

Typically, traders will manually draw lines across the swing highs and swing lows of both the price chart and the oscillator to see whether they appear to present a divergence, this indicator will draw them for you, quickly and clearly, and can notify you when they occur.


Disclaimer: This script includes code from several stock indicators by Tradingview as well as the Divergence for Many Indicators v4 by LonesomeTheBlue. With special thanks.
Release Notes
- Updated screenshot
Release Notes
- Corrected the colour of the 2 TSI line and TSI lagline, so green is now above red when turning up, and red is now above green when turning down.
Release Notes
- Updated screenshot to reflect change to the TSI band colours.
Release Notes
- Fixed a bug where the osc line was using the custom colours when the 'Enable custom line colors' option was not enabled.
Release Notes
- Fixed the Stoch RSI so it works properly with a different timeframe selected other than the current chart.
Release Notes
- Added a "Double centerline crossover" feature which will use the background crossover color, when enabled, so show when both the primary and secondary selected oscillators have both crossed above or below their centerlines, as opposed to just the primary oscillator. This is intended for use typically with the UO or MFI, and using the RSI or TSI as the secondary oscillator, whose centerline crossover is often used as a means of guaging bullishness or bearishness, and which cross their centerlines less frequently than for example, the UO and TSI. This setting is disabled by default. Seconday oscillator is set to RSI by default.
Release Notes
- Added a 'Flip oscillator' feature into the settings for use with the Tradingview 'Flip chart' (Alt+i) feature, so both the chart and the oscillators can both be flipped upside down to help see the opposite scenario for traders who have a strong natural bias for a given direction. For the purpose of manually spotting divergences.
- Added a 'flipped' warning label to the oscillator panel to show when the osc is flipped.
- Set the default oscillator line width to 2 on oscillators that have just one line.
Release Notes
- Added CDV candle & Heikin Ashi candle presentation options alongside line. Code adapted from original CDV indicator by Lonesometheblue. With thanks.
Release Notes
- Removed the unused source input option from pivot period settings.
Release Notes
- Added the histogram to the TSI.
- Removed the double centerline crossover background colour feature.
- Updated chart image.
Release Notes
- Added a "max_bars_back=1000" to avoid error on higher TF TSV
- Updated default value of TSV MA length from 3, to 7.
Release Notes
- Replaced CDV code with code from CDV indicator by Ankit_1618 which includes ema cloud and ema crossover signals.
- Remove the auto adjust pivot period based on current chart timeframe feature.
Release Notes
- Updated chart image to reflect new CDV.
Release Notes
- Fixed the CDV specific setting so that it presents the CDV either as a line or as columns, based on the selection within the settings menu. Previously selecting "Line" did not hide the CDV histogram columns etc.
Release Notes
- Added an option for CCI.
Release Notes
- Adjusted the centerline and range band levels for the CCI.
Release Notes
- Added centerline to CDV option.
CDVDivergenceMFIOscillatorsrealtimeRelative Strength Index (RSI)True Strength Index (TSI)TSItsvuo

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer