🔸Adaptive Mechanisms
🔸Multi-Faceted Analysis
🔸Versatility Across Timeframes
🔸Multi-Scale Combination
🔸Hurst Exponent (H)🞘 How it works
🞘 How to calculate
🞘 Code extract
🔸Conditional Value at Risk (CVaR)🞘 How it works
🞘 How to calculate
🞘 Code extract
🔸Fractal Dimension (FD)🞘 How it works
🞘 How to calculate
🞘 Code extract
🔸Step-by-Step Guidelines🞘 Setting Up the Indicator🔸Customize settings
🞘 Understanding What to Look For on the Chart
🞘 Possible Entry Signals
🞘 Possible Take Profit Strategies
🞘 Possible Stop-Loss Levels
🞘 Additional Tips
The Multi-Scale Adaptive MAs (Hurst, CVaR, Fractal) indicator stands out due to its unique approach of dynamically adjusting moving averages based on advanced statistical measures, making it highly responsive to varying market conditions. Unlike traditional moving averages that rely on static periods, this indicator adapts in real-time using three distinct adaptive methods: Hurst Exponent, CVaR, and Fractal Dimension.
🔸Adaptive MechanismsTraditional MA indicators use fixed lengths, which can lead to lagging signals or over-sensitivity in volatile markets. The Multi-Scale Adaptive MAs employ adaptive methods to adjust the MA length dynamically, providing a more accurate reflection of current market conditions.
🔸Multi-Faceted AnalysisBy integrating Hurst Exponent, CVaR, and Fractal Dimension, the indicator offers a comprehensive market analysis. It captures different aspects of market behavior, including trend persistence, risk of extreme movements, and complexity, which are often missed by standard MAs.
🔸Versatility Across TimeframesThe indicator’s ability to switch between different adaptive methods based on market conditions allows traders to analyze short-term, medium-term, and long-term trends with enhanced precision.
🔸Multi-Scale CombinationUtilizing multiple adaptive MAs in combination provides a more nuanced view of the market, allowing traders to see how short, medium, and long-term trends interact. This layered approach helps in identifying the strength and consistency of trends across different scales, offering more reliable signals and aiding in complex decision-making processes. When combined, these MAs can also signal key market shifts when they converge or diverge, offering deeper insights than a single MA could provide.
The indicator adjusts moving averages based on a variety of different choosable adaptives. The Hurst Exponent to identify trend persistence or mean reversion, adapting to market conditions for both short-term and long-term trends. Using CVaR, it evaluates the risk of extreme price movements, ensuring the moving average is more conservative during high-risk periods, protecting against potential large losses. By incorporating the Fractal Dimension, the indicator adapts to market complexity, adjusting to varying levels of price roughness and volatility, which allows it to respond more accurately to different market structures and patterns.
Let's dive into the details:
🔸Hurst Exponent (H)
- Measures the degree of trend persistence or mean reversion.
- By using the Hurst Exponent, the indicator adjusts to capture the strength and duration of trends, helping traders to stay in profitable trades longer and avoid false reversals in ranging markets.
- It enhances the detection of trends, making it suitable for both short-term scalping and identifying long-term trends.
🞘 How it worksRescaled Range (R/S) Analysis
- Calculate the mean of the closing prices over a set window.
- Determine the deviation of each price from the mean.
- Compute the cumulative sum of these deviations over the window.
- Calculate the range (R) of the cumulative deviations (maximum minus minimum).
- Compute the standard deviation (S) of the price series over the window.
- Obtain the R/S ratio as R/S.
Linear Regression for Hurst Exponent
- Calculate the logarithm of multiple window sizes and their corresponding R/S values.
- Use linear regression to determine the slope of the line fitting the log(R/S) against log(window size).
- The slope of this line is an estimate of the Hurst Exponent.
🞘 How to calculateRange (R)
Calculate the maximum cumulative deviation:
R=max(sum(deviation))−min(sum(deviation))
Where deviation is the difference between each price and the mean.
Standard Deviation (S)
Calculate the standard deviation of the price series:
S=sqrt((1/(n−1))∗sum((Xi−mean)2))
Rescaled Range (R/S)
Divide the range by the standard deviation:
R/S=R/S
Hurst Exponent
Perform linear regression to estimate the slope of:
log(R/S) versus log(windowsize)
The slope of this line is the Hurst Exponent.
🞘 Code extract
🔸Conditional Value at Risk (CVaR)
- Assesses the risk of extreme losses by focusing on tail risk.
- This method adjusts the moving average to account for market conditions where extreme price movements are likely, providing a more conservative approach during periods of high risk.
- Traders benefit by better managing risk and avoiding major losses during volatile market conditions.
🞘 How it worksCalculate Returns
- Determine the returns as the percentage change between consecutive closing prices over a specified window.
Percentile Calculation
- Identify the percentile threshold (e.g., the 5th percentile) for the worst returns in the dataset.
Average of Extreme Losses
- Calculate the average of all returns that are less than or equal to this percentile, representing the CVaR.
🞘 How to calculateReturn Calculation
Calculate the return as the percentage change between consecutive prices:
Return = (Pt − Pt−1) / Pt−1
Where Pt is the price at time t.
Percentile Threshold
Identify the return value at the specified percentile (e.g., 5th percentile):
PercentileValue=percentile(returns,percentile_threshold)
CVaR Calculation
Compute the average of all returns below the percentile threshold:
CVaR = (1/n)∗sum(Return) for all Return≤PercentileValue
Where n is the total number of returns.
🞘 Code extract
🔸Fractal Dimension (FD)
- Evaluates market complexity and roughness by analyzing how price movements behave across different scales.
- It enables the moving average to adapt based on the level of market noise or structure, allowing for smoother MAs during complex, volatile periods and more sensitive MAs during clear trends.
- This adaptability is crucial for traders dealing with varying market states, improving the indicator's responsiveness to price changes.
🞘 How it worksTotal Distance (L) Calculation
- Sum the absolute price movements between consecutive periods over a given window.
Maximum Distance (D) Calculation
- Calculate the maximum displacement from the first to the last price point within the window.
Calculate Fractal Dimension
- Use Katz's method to estimate the Fractal Dimension as the ratio of the logarithms of L and D, divided by the logarithm of the number of steps (N).
🞘 How to calculateTotal Distance (L)
Sum the absolute price changes over the window:
L=sum(abs(Pt−Pt−1)) for t from 2 to n
Where Pt is the price at time t.
Maximum Distance (D)
Find the maximum absolute displacement from the first to the last price in the window:
D=max(abs(Pn-P1))
Fractal Dimension Calculation
Use Katz's method to estimate fractal dimension:
FD=log(L/D)/log(N)
Where N is the number of steps in the window.
🞘 Code extract
The Multi-Scale Adaptive MAs indicator can be set up by adding it to your TradingView chart and configuring the adaptive method (Hurst, CVaR, or Fractal) to match current market conditions. Look for price crossovers and changes in the slope for potential entry signals. Set take profit and stop-loss levels based on dynamic changes in the moving average, and consider combining it with other indicators for confirmation. Adjust settings and use adaptive strategies for enhanced trend detection and risk management.
🔸Step-by-Step Guidelines🞘 Setting Up the IndicatorAdding the Indicator to the Chart:
- Go to your TradingView chart.
- Click on the "Indicators" button at the top.
- Search for "Multi-Scale Adaptive MAs (Hurst, CVaR, Fractal)" in the indicators list.
- Click on the indicator to add it to your chart.
Configuring the Indicator:
- Open the indicator settings by clicking on the gear icon next to its name on the chart.
- Adaptive Method: Choose between "Hurst," "CVaR," and "Fractal" depending on the market condition and your trading style.
- Length: Set the base length for the moving average (e.g., 20, 50, or 100). This length will be adjusted dynamically based on the selected adaptive method.
- Other Parameters: Adjust any other parameters as needed, such as window sizes or scaling factors specific to each adaptive method.
Chart Setup:
- Ensure you have an appropriate timeframe selected (e.g., 1-hour, 4-hour, daily) based on your trading strategy.
- Consider using additional indicators like volume or RSI to confirm signals.
🞘 Understanding What to Look For on the ChartIndicator Behavior:
- Observe how the adaptive moving average (AMA) behaves compared to standard moving averages, e.g. notice how it might change direction with strength (Hurst).
- For example, the AMA may become smoother during high market volatility (CVaR) or more responsive during strong trends (Hurst).
Crossovers:
- Look for crossovers between the price and the adaptive moving average.
- A bullish crossover occurs when the price crosses above the AMA, suggesting a potential uptrend.
- A bearish crossover occurs when the price crosses below the AMA, indicating a possible downtrend.
Slope and Direction:
- Pay attention to the slope of the AMA. A rising slope suggests a bullish trend, while a declining slope indicates a bearish trend.
- The slope’s steepness can give you clues about the trend's strength.
🞘 Possible Entry SignalsBullish Entry:
- Crossover Entry: Enter a long position when the price crosses above the AMA and the AMA has a positive slope.
- Confirmation Entry: Combine the crossover with other indicators like RSI (above 50) or increasing volume for confirmation.
Bearish Entry:
- Crossover Entry: Enter a short position when the price crosses below the AMA and the AMA has a negative slope.
- Confirmation Entry: Use additional indicators like RSI (below 50) or decreasing volume to confirm the bearish trend.
Adaptive Method Confirmation:
- Hurst: Enter when the AMA indicates a strong trend (steeper slope). Suitable for trend-following strategies.
- CVaR: Be cautious during high-risk periods. Enter only if confirmed by other indicators, as the AMA may become more conservative.
- Fractal: Ideal for capturing reversals in complex markets. Look for crossovers in volatile markets.
🞘 Possible Take Profit StrategiesStatic Take Profit Levels:
- Set take profit levels based on predefined ratios (e.g., 1:2 or 1:3 risk-reward ratio).
- Place take profit orders at recent swing highs (for long positions) or swing lows (for short positions).
Trailing Stop Loss:
- Use a trailing stop based on a percentage of the AMA value to lock in profits as the trend progresses.
- Adjust the trailing stop dynamically to follow the AMA, allowing profits to run while protecting gains.
Adaptive Method Based Exits:
- Hurst: Exit when the AMA begins to flatten or turn in the opposite direction, signaling a potential trend reversal.
- CVaR: Consider taking profits earlier during high-risk periods when the AMA suggests caution.
- Fractal: Use the AMA to exit in complex markets when it smooths out, indicating reduced volatility.
🞘 Possible Stop-Loss LevelsInitial Stop Loss:
- Place an initial stop loss below the AMA (for long positions) or above the AMA (for short positions) to protect against adverse movements.
- Use a buffer (e.g., ATR value) to avoid being stopped out by normal price fluctuations.
Adaptive Stop Loss:
- Adjust the stop loss dynamically based on the AMA. Move the stop loss along the AMA as the trend progresses to minimize risk.
- This helps in adapting to changing market conditions and avoiding premature exits.
Adaptive Method-Specific Stop Loss:
- Hurst: Use wider stops during trending markets to allow for minor pullbacks.
- CVaR: Adjust stops in high-risk periods to avoid being stopped out prematurely during price fluctuations.
- Fractal: Place stops at recent support/resistance levels in highly volatile markets.
🞘 Additional TipsCombine with Other Indicators:
- Enhance your strategy by combining the AMA with other technical indicators like MACD, RSI, or Bollinger Bands for better signal confirmation.
Backtesting and Practice:
- Backtest the indicator on historical data to understand how it performs in different market conditions.
- Practice using the indicator on a demo account before applying it to live trading.
Market Awareness:
- Always be aware of market conditions and fundamental events that might impact price movements, as the AMA reacts to price action and may not account for sudden news-driven events.
🔸Customize settings🞘 Time Override: Enables or disables the ability to override the default time frame for the moving averages. When enabled, you can specify a custom time frame for the calculations.
🞘 Time: Specifies the custom time frame to use when the Time Override setting is enabled.
🞘 Enable MA: Enables or disables the moving average. When disabled, MA will not be displayed on the chart.
🞘 Show Smoothing Line: Enables or disables the display of a smoothing line for the moving average. The smoothing line helps to reduce noise and provide a clearer trend.
🞘 Show as Horizontal Line: Displays the moving average as a horizontal line instead of a dynamic line that follows the price.
🞘 Source: Specifies the data source for the moving average calculation (e.g., close, open, high, low).
🞘 Length: Sets the period length for the moving average. A longer length will result in a smoother moving average, while a shorter length will make it more responsive to price changes.
🞘 Time: Specifies a custom time frame for the moving average, overriding the default time frame if Time Override is enabled.
🞘 Method: Selects the calculation method for the moving average (e.g., SMA, EMA, SMMA, WMA, VWMA).
🞘 Offset: Shifts the moving average forward or backward by the specified number of bars.
🞘 Color: Sets the color for the moving average line.
🞘 Adaptive Method: Selects the adaptive method to dynamically adjust the moving average based on market conditions (e.g., Hurst, CVaR, Fractal).
🞘 Window Size: Sets the window size for the adaptive method, determining how much historical data is used for the calculation.
🞘 CVaR Scaling Factor: Adjusts the influence of CVaR on the moving average length, controlling how much the length changes based on calculated risk.
🞘 CVaR Risk: Specifies the percentile cutoff for the worst-case returns used in the CVaR calculation to assess extreme losses.
🞘 Smoothing Method: Selects the method for smoothing the moving average (e.g., SMA, EMA, SMMA, WMA, VWMA).
🞘 Smoothing Length: Sets the period length for smoothing the moving average.
🞘 Fill Color to Smoothing Moving Average: Enables or disables the color fill between the moving average and its smoothing line.
🞘 Transparency: Sets the transparency level for the color fill between the moving average and its smoothing line.
🞘 Show Label: Enables or disables the display of a label for the moving average on the chart.
🞘 Show Label for Smoothing: Enables or disables the display of a label for the smoothing line of the moving average on the chart.
The Multi-Scale Adaptive MAs indicator offers a sophisticated approach to trend analysis and risk management by dynamically adjusting moving averages based on Hurst Exponent, CVaR, and Fractal Dimension. This adaptability allows traders to respond more effectively to varying market conditions, capturing trends and managing risks with greater precision. By incorporating advanced statistical measures, the indicator goes beyond traditional moving averages, providing a nuanced and versatile tool for both short-term and long-term trading strategies. Its unique ability to reflect market complexity and extreme risks makes it an invaluable asset for traders seeking a deeper understanding of market dynamics.
Ce script est publié en code source fermé et vous pouvez l'utiliser librement. Vous pouvez le préférer pour l'utiliser sur un graphique. Vous ne pouvez pas visualiser ou modifier son code source.