Money Flow Index Crossover IndicatorThe "Money Flow Index Crossover Indicator" is a specialized technical analysis tool designed to assist traders by providing a clear visualization of potential buy and sell signals based on the Money Flow Index (MFI) and its smoothed moving average (SMA). This indicator delineates overbought and oversold zones, offering valuable insights into market dynamics. It operates as an oscillator on a separate pane, helping traders identify bullish and bearish market conditions with greater precision. By incorporating k-Nearest Neighbor (KNN) machine learning techniques, this indicator enhances the reliability and accuracy of the signals provided.
Originality and Usefulness:
This script is not just a simple mashup of existing indicators but integrates multiple components to create a unique and comprehensive analysis tool. The combined information from the MFI, its smoothed moving average, and the KNN machine learning techniques influence the form and accuracy of the Money Flow Index Average line and the Smoothed Money Flow Index line giving a visually helpful representation of overbought and oversold conditions. These lines are displayed in an oscillator style crossover, allowing users to visualize potential buy and sell zones for setting up potential signals. The user can adjust various settings of these tools behind the code to fine-tune the behavior and sensitivity of these lines. This integration provides a more robust and insightful trading tool that can adapt to different market conditions and trading styles.
How It Works:
Inputs:
MFI Settings:
Show Signals: Allows users to toggle the display of MFI and SMA crossing signals, which are critical for identifying potential market reversals.
Plot Amount: Determines the number of plots in the heat map, ranging from 2 to 28, enabling customization based on user preference.
Source: Defines the data source for MFI calculations, typically set to OHLC4 for a balanced view of price movements.
Smooth Initial MFI Length: Specifies the smoothing length for the initial MFI calculations to reduce noise and enhance signal clarity.
MFI SMA Length: Sets the length for the SMA used to smooth the MFI average, providing a more stable reference line.
Machine Learning Settings:
Use KInSource: Option to average MFI data by adding a lookback to the source, improving the accuracy of historical comparisons.
KNN Distance Requirement: Defines the distance calculation method for KNN (Max, Min, Both) to refine the data filtering process.
Machine Learning Length: Specifies the amount of machine learning data stored for smoothing results, balancing between responsiveness and stability.
KNN Length: Sets the number of KNN used to calculate the allowable distance range, enhancing the precision of the machine learning model.
Fast and Slow Lengths: Defines the lengths for fast and slow MFI calculations, allowing the indicator to capture different market dynamics.
Smoothing Length: Determines the length at which MFI calculations start for a more smoothed result, reducing false signals.
Variables and Functions:
KNN Function: Filters machine learning data to calculate valid distances based on defined criteria, ensuring more accurate MFI averages.
MFI Calculations: Computes both fast and slow MFI values, applies smoothing, and stores them for KNN processing to refine signal generation.
MFI KNN Calculation: Uses the KNN function to calculate the machine learning average of MFI values, enhancing signal reliability.
MFI Average and SMA: Calculates the average and smoothed MFI values, which are crucial for determining crossover signals.
Calculations:
MFI Values: Calculates current fast and slow MFI values and applies smoothing to reduce market noise.
Storage Arrays: Stores MFI data in arrays for KNN processing, enabling historical comparison and pattern recognition.
KNN Processing: Computes the machine learning average of MFI values using the KNN function, improving the robustness of signals.
MFI Average: Scales the MFI average to fit the heat map and calculates the smoothed SMA, providing a clear visual representation of trends.
Crossover Signals: Identifies bullish (MFI crossing above SMA) and bearish (MFI crossing below SMA) signals, which are key for making trading decisions.
Plots and Visuals:
MFI Average and SMA Lines: Plots the MFI average and smoothed SMA on the chart, allowing traders to easily visualize market trends and potential reversals.
Zones: Defines and plots overbought, neutral, and oversold zones for easy visualization. The recommended settings for these zones are:
Overbought Zone: Level set to approximately 24.6, indicating a potential market top.
Neutral Zone: Level set to 14, representing a balanced market condition.
Oversold Zone: Level set to 5.4, signaling a potential market bottom.
Crossover Marks: Plots circles on the chart to indicate bullish and bearish crossover signals, making it easier to spot entry and exit points.
Visual Alerts:
Bullish and Bearish Alerts: one can see overbought and oversold conditions and up alert conditions for bullish and bearish MFI crossover signals, enabling traders to have access to visual cues when these events are on trajectory to occur and, if they occur, act promptly with the visual representation of its zones.
Why It's Helpful:
The "Money Flow Index Crossover Indicator" provides traders with a sophisticated tool to identify potential buy and sell conditions based on the combined information of the MFI and its smoothed moving average. The KNN machine learning techniques enhance the accuracy of this indicator's clear visual representation of overbought, neutral, and oversold zones. This combination of data represented on the chart helps traders make informed decisions about market conditions. This indicator is particularly useful for traders looking to refine their entry and exit points by leveraging advanced data analysis in respect to overbought and oversold conditions.
Disclaimer:
This indicator is intended to assist traders in making informed decisions based on technical analysis. However, it is not a guarantee of future performance and should be used in conjunction with other analysis techniques and risk management practices. Past performance is not indicative of future results, and traders should exercise caution and perform their own due diligence before making any trading decisions.
Oversold-condition
Bitcoin Power Law Bands (BTC Power Law) Indicator█ OVERVIEW
The 'Bitcoin Power Law Bands' indicator is a set of three US dollar price trendlines and two price bands for bitcoin , indicating overall long-term trend, support and resistance levels as well as oversold and overbought conditions. The magnitude and growth of the middle (Center) line is determined by double logarithmic (log-log) regression on the entire USD price history of bitcoin . The upper (Resistance) and lower (Support) lines follow the same trajectory but multiplied by respective (fixed) factors. These two lines indicate levels where the price of bitcoin is expected to meet strong long-term resistance or receive strong long-term support. The two bands between the three lines are price levels where bitcoin may be considered overbought or oversold.
All parameters and visuals may be customized by the user as needed.
█ CONCEPTS
Long-term models
Long-term price models have many challenges, the most significant of which is getting the growth curve right overall. No one can predict how a certain market, asset class, or financial instrument will unfold over several decades. In the case of bitcoin , price history is very limited and extremely volatile, and this further complicates the situation. Fortunately for us, a few smart people already had some bright ideas that seem to have stood the test of time.
Power law
The so-called power law is the only long-term bitcoin price model that has a chance of survival for the years ahead. The idea behind the power law is very simple: over time, the rapid (exponential) initial growth cannot possibly be sustained (see The seduction of the exponential curve for a fun take on this). Year-on-year returns, therefore, must decrease over time, which leads us to the concept of diminishing returns and the power law. In this context, the power law translates to linear growth on a chart with both its axes scaled logarithmically. This is called the log-log chart (as opposed to the semilog chart you see above, on which only one of the axes - price - is logarithmic).
Log-log regression
When both price and time are scaled logarithmically, the power law leads to a linear relationship between them. This in turn allows us to apply linear regression techniques, which will find the best-fitting straight line to the data points in question. The result of performing this log-log regression (i.e. linear regression on a log-log scaled dataset) is two parameters: slope (m) and intercept (b). These parameters fully describe the relationship between price and time as follows: log(P) = m * log(T) + b, where P is price and T is time. Price is measured in US dollars , and Time is counted as the number of days elapsed since bitcoin 's genesis block.
DPC model
The final piece of our puzzle is the Dynamic Power Cycle (DPC) price model of bitcoin . DPC is a long-term cyclic model that uses the power law as its foundation, to which a periodic component stemming from the block subsidy halving cycle is applied dynamically. The regression parameters of this model are re-calculated daily to ensure longevity. For the 'Bitcoin Power Law Bands' indicator, the slope and intercept parameters were calculated on publication date (March 6, 2022). The slope of the Resistance Line is the same as that of the Center Line; its intercept was determined by fitting the line onto the Nov 2021 cycle peak. The slope of the Support Line is the same as that of the Center Line; its intercept was determined by fitting the line onto the Dec 2018 trough of the previous cycle. Please see the Limitations section below on the implications of a static model.
█ FEATURES
Inputs
• Parameters
• Center Intercept (b) and Slope (m): These log-log regression parameters control the behavior of the grey line in the middle
• Resistance Intercept (b) and Slope (m): These log-log regression parameters control the behavior of the red line at the top
• Support Intercept (b) and Slope (m): These log-log regression parameters control the behavior of the green line at the bottom
• Controls
• Plot Line Fill: N/A
• Plot Opportunity Label: Controls the display of current price level relative to the Center, Resistance and Support Lines
Style
• Visuals
• Center: Control, color, opacity, thickness, price line control and line style of the Center Line
• Resistance: Control, color, opacity, thickness, price line control and line style of the Resistance Line
• Support: Control, color, opacity, thickness, price line control and line style of the Support Line
• Plots Background: Control, color and opacity of the Upper Band
• Plots Background: Control, color and opacity of the Lower Band
• Labels: N/A
• Output
• Labels on price scale: Controls the display of current Center, Resistance and Support Line values on the price scale
• Values in status line: Controls the display of current Center, Resistance and Support Line values in the indicator's status line
█ HOW TO USE
The indicator includes three price lines:
• The grey Center Line in the middle shows the overall long-term bitcoin USD price trend
• The red Resistance Line at the top is an indication of where the bitcoin USD price is expected to meet strong long-term resistance
• The green Support Line at the bottom is an indication of where the bitcoin USD price is expected to receive strong long-term support
These lines envelope two price bands:
• The red Upper Band between the Center and Resistance Lines is an area where bitcoin is considered overbought (i.e. too expensive)
• The green Lower Band between the Support and Center Lines is an area where bitcoin is considered oversold (i.e. too cheap)
The power law model assumes that the price of bitcoin will fluctuate around the Center Line, by meeting resistance at the Resistance Line and finding support at the Support Line. When the current price is well below the Center Line (i.e. well into the green Lower Band), bitcoin is considered too cheap (oversold). When the current price is well above the Center Line (i.e. well into the red Upper Band), bitcoin is considered too expensive (overbought). This idea alone is not sufficient for profitable trading, but, when combined with other factors, it could guide the user's decision-making process in the right direction.
█ LIMITATIONS
The indicator is based on a static model, and for this reason it will gradually lose its usefulness. The Center Line is the most durable of the three lines since the long-term growth trend of bitcoin seems to deviate little from the power law. However, how far price extends above and below this line will change with every halving cycle (as can be seen for past cycles). Periodic updates will be needed to keep the indicator relevant. The user is invited to adjust the slope and intercept parameters manually between two updates of the indicator.
█ RAMBLINGS
The 'Bitcoin Power Law Bands' indicator is a useful tool for users wishing to place bitcoin in a macro context. As described above, the price level relative to the three lines is a rough indication of whether bitcoin is over- or undervalued. Users wishing to gain more insight into bitcoin price trends may follow the author's periodic updates of the DPC model (contact information below).
█ NOTES
The author regularly posts on Twitter using the @DeFi_initiate handle.
█ THANKS
Many thanks to the following individuals, who - one way or another - made the 'Bitcoin Power Law Bands' indicator possible:
• TradingView user 'capriole_charles', whose open-source 'Bitcoin Power Law Corridor' script was the basis for this indicator
• Harold Christopher Burger, whose Bitcoin’s natural long-term power-law corridor of growth article (2019) was the basis for the 'Bitcoin Power Law Corridor' script
• Bitcoin Forum user "Trololo", who posted the original power law model at Logarithmic (non-linear) regression - Bitcoin estimated value (2014)