OPEN-SOURCE SCRIPT

MA Deviation Suite [InvestorUnknown]

This indicator combines advanced moving average techniques with multiple deviation metrics to offer traders a versatile tool for analyzing market trends and volatility.

Moving Average Types:
  • SMA, EMA, HMA, DEMA, FRAMA, VWMA: Standard moving averages with different characteristics for smoothing price data.
  • Corrective MA: This method corrects the MA by considering the variance, providing a more responsive average to price changes.


  • Fisher Least Squares MA: Aims to reduce lag by using a Fisher Transform on residuals.


  • Sine-Weighted MA & Cosine-Weighted MA: These give more weight to middle bars, creating a smoother curve; Cosine weights are shifted for a different focus.


Deviation Metrics:
  • Average Absolute Deviation (AAD) and Median Absolute Deviation (MAD): AAD calculates the average of absolute deviations from the MA, offering a measure of volatility. MAD uses the median, which can be less sensitive to outliers.
  • Standard Deviation (StDev): Measures the dispersion of prices from the mean.
  • Average True Range (ATR): Reflects market volatility by considering the day's range.
  • Average Deviation (adev): The average of previous deviations.



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.


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.

스냅샷

Practical Usage and Calibration
Default settings are not optimized: The given parameters serve as a starting point for demonstration. Users should adjust:
  • len: Affects how smooth and lagging the moving average 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.

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

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항