Money Flow Index Divergences [UAlgo]

🔶 Description:

This script aims providing traders with comprehensive insights into market dynamics. The indicator offers a multi-faceted approach to technical analysis, encompassing various features to enhance trading decision-making:

🔶Key Features:

Money Flow Index Oscillator Settings: Users can customize the length of the MFI oscillator and the confluence bar length to suit their trading preferences.

Gradient Color Visualization: The indicator utilizes gradient colors to visually represent the MFI oscillator, with colors shifting based on MFI values for enhanced clarity.

Confluence Area Calculation: A confluence area is calculated based on the specified length, providing additional context for MFI movements (Aims to provide longer-term information).

Divergence Detection: The script identifies bullish and bearish divergences by comparing price action with MFI oscillator movements, aiding traders in spotting potential trend reversals.

Customizable Sensitivity: Traders can adjust the sensitivity settings for divergence detection according to their trading strategies.


MFI Calculation:

The script starts by calculating the Money Flow Index (MFI) using the ta.mfi() function, which takes the typical price (hlc3) and a length parameter (default set to 14). The MFI is normalized to a range between 0 and 1 for color gradient calculations.

Another MFI is calculated with a longer length (lengthConfluence, default set to 50) for confluence analysis. Similar to the MFI calculation, the highest and lowest MFI values within the confluence length are determined. The MFI values within the confluence length are normalized. The normalized MFI values are used to calculate the gradient color for the confluence area.

Gradient Color Calculations:

Two sets of RGB color values (redRGB, greenRGB, blueRGB) and (redRGB2, greenRGB2, blueRGB2) are defined to create a gradient color scheme for the MFI plot. The MFI value is normalized between the highest and lowest MFI values within the specified length. The normalized MFI value is then used to calculate the red, green, and blue components of the gradient color.

Plotting Confluence Area:

Two horizontal lines (upperArea and lowerArea) are plotted to highlight the confluence area.
The area between these lines is filled with the gradient color representing MFI confluence.
Divergence Calculations:

Bullish and bearish divergences are identified based on specific conditions related to the MFI and price action.

Bullish divergence occurs when the MFI makes a lower low while price makes a higher low.

Bearish divergence occurs when the MFI makes a higher high while price makes a lower high.

The sensitivity (Pivot calculation length) of divergence detection can be adjusted.

Overall, this script provides a comprehensive analysis of the Money Flow Index, including plotting the MFI with a gradient color scheme, identifying confluence areas, and detecting bullish and bearish divergences to aid traders in making informed decisions.


-This script is provided for informational and educational purposes only and should not be considered financial advice.

-Trading involves risk, and users should conduct their own research and analysis before making any investment decisions.

-The author of this script and UAlgo are not liable for any losses incurred as a result of using this indicator.

-Users are encouraged to exercise caution and practice risk management when trading in the financial markets.

Get access to our exclusive tools:

Join Our Discord For Updates:

All scripts & Content Provided by UAlgo Are For Informational & Educational Purposes Only.
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 a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?