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.

syot kilat

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

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian