OPEN-SOURCE SCRIPT

Median Deviation Suite [InvestorUnknown]

The Median Deviation Suite uses a median-based baseline derived from a Double Exponential Moving Average (DEMA) and layers multiple deviation measures around it. By comparing price to these deviation-based ranges, it attempts to identify trends and potential turning points in the market. The indicator also incorporates several deviation types—Average Absolute Deviation (AAD), Median Absolute Deviation (MAD), Standard Deviation (STDEV), and Average True Range (ATR)—allowing traders to visualize different forms of volatility and dispersion. Users should calibrate the settings to suit their specific trading approach, as the default values are not optimized.

anlık görüntü

Core Components

Median of a DEMA:
The foundation of the indicator is a Median applied to the 7-day DEMA (Double Exponential Moving Average). DEMA aims to reduce lag compared to simple or exponential moving averages. By then taking a median over median_len periods of the DEMA values, the indicator creates a robust and stable central tendency line.



Multiple Deviation Measures:
Around this median, the indicator calculates several measures of dispersion:
  • ATR (Average True Range): A popular volatility measure.
  • STDEV (Standard Deviation): Measures the spread of price data from its mean.
  • MAD (Median Absolute Deviation): A robust measure of variability less influenced by outliers.
  • AAD (Average Absolute Deviation): Similar to MAD, but uses the mean absolute deviation instead of median.
  • Average of Deviations (avg_dev): The average of the above four measures (ATR, STDEV, MAD, AAD), providing a combined sense of volatility.

Each measure is multiplied by a user-defined multiplier (dev_mul) to scale the width of the bands.



Deviation-Based Bands:
The indicator creates multiple upper and lower lines based on each deviation type. For example, using MAD:



Similar calculations are done for AAD, STDEV, ATR, and the average of these deviations. The indicator then determines the overall upper and lower boundaries by combining these lines:



This creates a layered structure of volatility envelopes. Traders can observe which layers price interacts with to gauge trend strength.

Determining Trend
The indicator generates trend signals by assessing where price stands relative to these deviation-based lines. It assigns a trend score by summing individual signals from each deviation measure. For instance, if price crosses above the MAD-based upper line, it contributes a bullish point; crossing below an ATR-based lower line contributes a bearish point.
When the aggregated trend score crosses above zero, it suggests a shift towards a bullish environment; crossing below zero indicates a bearish bias.



Practical Usage and Calibration
Default settings are not optimized: The given parameters serve as a starting point for demonstration. Users should adjust:
  • median_len: Affects how smooth and lagging the median of the DEMA is.
  • dev_len and dev_mul: Influence the sensitivity of the deviation measures. Larger multipliers widen the bands, potentially reducing false signals but introducing more lag. Smaller multipliers tighten the bands, producing quicker signals but potentially more whipsaws.

This flexibility allows the trader to tailor the indicator for various markets (stocks, forex, crypto) and time frames.

Backtesting and Performance Metrics
The code integrates with a backtesting library that allows traders to:
  • Evaluate the strategy historically
  • Compare the indicator’s signals with a simple buy-and-hold approach
  • Generate performance metrics (e.g., mean returns, Sharpe Ratio, Sortino Ratio) to assess historical effectiveness.


anlık görüntü

Disclaimer
  • No guaranteed results: Historical performance does not guarantee future outcomes. Market conditions can vary widely.
  • User responsibility: Traders should combine this indicator with other forms of analysis, appropriate risk management, and careful calibration of parameters.




statisticsTrend AnalysisVolatility

Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının yazarı komut dosyasını açık kaynak olarak yayınlamıştır, böylece yatırımcılar betiği anlayabilir ve doğrulayabilir. Yazar çok yaşa! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun yayında yeniden kullanımı Ev kurallarına tabidir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?

Feragatname