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.

Snapshot

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

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?

Haftungsausschluss