OPEN-SOURCE SCRIPT

UFO + Realtime Divergences (UO x MFI)

Updated
UFO + Realtime Divergences (UO x MFI) + Alerts

The UFO is a hybrid of two powerful oscillators - the Ultimate Oscillator (UO) and the Money Flow Index (MFI)

Features of the UFO include:

- Optional divergence lines drawn directly onto the oscillator in realtime.
- Configurable alerts to notify you when divergences occur, as well as centerline crossovers.
- Configurable lookback periods to fine tune the divergences drawn in order to suit different trading styles and timeframes.
- Background colouring option to indicate when the oscillator has crossed 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.
- 2x MTF triple-timeframe Stochastic RSI overbought and oversold confluence signals painted at the top of the panel for use as a confluence for reversal entry trades.

The core calculations of the UFO+ combine the factory settings of the Ultimate Oscillator and Money Flow Index, taking an average of their combined values for its output eg:

UO_Value + MFI_Value / 2

The result is a powerful oscillator capable of detecting high quality divergences, including on very low timeframes and highly volatile markets, it benefits from the higher weighting of the most recent price action provided by the Ultimate Oscillators calculations, as well as the calculation of the MFI, which incorporates volume data. The UFO and its incorporated 2x triple-timeframe MTF Stoch RSI overbought and oversold signals makes it well adapted for low timeframe scalping and regular divergence trades in particular.


The Ultimate Oscillator (UO)

Tradingview describes the Ultimate Oscillator as follows:

“The Ultimate Oscillator indicator (UO) 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.”

You can read more about the UO and its calculations here


The Money Flow Index ( MFI )

Investopedia describes the True Strength Indicator as follows:

“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 .”

You can read more about the MFI and its calculations here


The Stochastic RSI (relating to the built-in MTF Stoch RSI feature)

The popular oscillator has been described as follows:

“The Stochastic RSI 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 Stochastic RSI 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.”

You can read more about the Stochastic RSI and its calculations here


How do traders use overbought and oversold levels in their trading?

The oversold level, that is when the Stochastic RSI is above the 80 level is typically interpreted as being 'overbought', and below the 20 level is typically considered 'oversold'. Traders will often use the Stochastic RSI at an overbought level as a confluence for entry into a short position, and the Stochastic RSI at an oversold level as a confluence for an entry into a long position. These levels do not mean that price will necessarily reverse at those levels in a reliable way, however. This is why this version of the Stoch RSI employs the triple timeframe overbought and oversold confluence, in an attempt to add a more confluence and reliability to this usage of the Stoch RSI .


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.


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.


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 period.

You can adjust the default pivot lookback values 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.


Disclaimer: This script includes code from the stock UO and MFI by Tradingview as well as the Divergence for Many Indicators v4 by LonesomeTheBlue.
Release Notes
- Refactored the MTF Stoch RSI confluence signal code to save height space on the panel.
- Added a an option for users to select where the MTF Stoch RSI Triple timeframe signal are positioned, Top, Bottom, or Absolute. Default set to Top.
Release Notes
- Corrected the MTF Stoch RSI ribbon signal code
- Adjusted the default secondary set of MTF triple-timeframe confluences to use 15m + 30m + 120m timeframes by default.
Release Notes
- Adjusted the MTF Stoch RSI code.
- Differentiated the colors of MTF#1 from MTF#2 for Stoch RSI overbought / oversold signals.
Release Notes
- Added a feature to optionally fade out the oscillator behind the most recent history.
- Updated the chart image.
- Defaulted the Range bands to disabled.
Release Notes
- Updated chart image
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 be flipped upside down to help see the opposite scenario for traders who have too one-sided a bias.
- Reorganised the settings menu to place the common settings at the top.
Release Notes
- Added a 'flipped' warning label to the oscillator panel to show when the osc is flipped.
Release Notes
- Added an additional set of MTF signals for a triple timeframe CCI, in additional to the existing triple timeframe MTF Stoch RSI, both showing MTF overbought and oversold periods.
- Added optional text label to panel to notify when either MTF CCI or MTF Stoch RSI reach overbought or oversold. Disabled by default.
- Adjusted the default MTF signal position to be 'Absolute' which places the MTF signals at the bottom of the panel, clear away from the oscillator itself.
- Added optional bar/candle coloring option for the MTF signals. Disabled by default.
- Enabled the centerline by default.
- Disabled the 'Fadeout oscillator' Feature by default.
Release Notes
- Removed the unused source input option from pivot period settings.
Release Notes
- Corrected the alert message text.
- Fixed the text label shown when osc is in 'Flip oscillator' mode, or optionally when MTF Stoch RSI / CCI confluences are met.
Release Notes
- Added option to customise oscillator colour into settings menu.
Release Notes
- Updated alerts so that multiple alerts are not triggered per instance of MTF or divergence signals.
- Enabled the highlight overbought and oversold highlight on oscillator by default.
- Removed the centerline crossover alerts.
Release Notes
- Fixed the MTF overbought/oversold alerts so they include the MTF CCI ob/os as well as the existing MTF Stoch RSI ob/os signals.
- Named and grouped alerts together more clearly.
Release Notes
- Removed the auto adjust pivot period for selected chart timeframe feature.
Release Notes
- Added a general background colour option.
- Improved the centerline crossunder back ground colour and oscillator colour settings, and default colours.
Release Notes
- Grouped all background colour styles in settings menu
Release Notes
- Added an optional table to show the values of the Stoch RSI and CCI on each of the timeframes used in the MTF signals. Colour coded values when they reach the defined overbought and oversold threshold levels.
Release Notes
- Turned on the MTF OB/OS label by default, added colour-coding to the text, inherited from the configurable OB/OS colours within settings for Stoch RSI and CCI. This tells users which oscillator - CCI or Stoch RSI is adding the signal to the panel, in the event that the colours are not distinct enough, or colour blind users. eg, label will read: "MTF Stoch RSI Overbought" in bottom left corner of panel.
Release Notes
- Added a option to select 'Dark' or 'Light' theme mode for MTF table which changes the labels between white/black
- Added a global control to show / hide MTF ribbon signals
- Added an option to include the current timeframe overbought and oversold Stoch RSI signals into the irron, disabled by default.
- Reorganised settings menu.
FLOWindexMFImoneyMoney Flow Index (MFI)multitimeframeultimateUltimate Oscillator (UO)uo

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