MC2021TM

Dynamic 5-Day Moving Average

The Dynamic 5-Day Moving Average (MA) indicator is designed to provide traders with a consistent, time-adjusted moving average line across various timeframes. This indicator is especially useful for traders who switch between multiple timeframes and want a moving average that represents a fixed 5-day period, ensuring that the MA reflects a consistent lookback period relative to the amount of trading time each candle represents.

Features:

  • Timeframe Adaptability: Automatically adjusts the MA period to correspond to a 5-day lookback, regardless of the selected timeframe.
  • Intraday Precision: For intraday charts (5m, 15m, 30m, 1h, 2h, 4h), the indicator calculates the number of periods within the 5-day span based on the chart's timeframe.
  • Daily and Weekly Timeframe Compatibility: Sets the period to 5 for daily charts to maintain the 5-day MA, and to 1 for weekly charts, where each candlestick represents a week's worth of trading days.

Calculation Logic:

  • The indicator begins by defining the total number of trading minutes in 5 days, based on a standard 6.5-hour trading day.
  • A dynamic period calculation function then determines the number of those intervals that fit into the 5-day minute total for the selected timeframe.
  • For daily charts, the period is a straightforward 5, while for weekly charts, the period is set to 1, reflecting the average of the past 5 trading days.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?