OPEN-SOURCE SCRIPT
Dynamic 5DMA/EMA with Color for Multiple Products

🔹 Dynamic 5DMA/EMA with Slope-Based Coloring (All Timeframes)
This indicator plots a dynamic 5-period moving average that adapts intelligently to your chart's timeframe and product type — giving you a clean, slope-sensitive visual edge across intraday, daily, and weekly views.
✅ Key Features:
📈 Dynamic MA Length Scaling:
On intraday timeframes, the MA adjusts for your selected market session (RTH, ETH, VIX, or Futures), calculating a true 5-day average based on actual session length — not just a flat bar count.
🔄 Automatic Timeframe Detection:
Daily Chart: Uses standard 5DMA or 5EMA.
Weekly Chart: Applies a true 5-week MA.
Intraday Charts: Converts 5 days into bar-length equivalent dynamically.
🎨 Color-Coded Slope Logic:
Green = Rising MA (bullish slope)
Red = Falling MA (bearish slope)
Neutral slope = previous color held for visual continuity
No more guessing — direction is instantly clear.
⚠️ Built-In Slope Flip Alerts:
Set alerts when the slope of the MA turns up or down. Ideal for timing pullback entries or exits across any product.
⚙️ Session Settings for Proper Scaling:
Choose your product's market structure to ensure accurate 5-day conversion on intraday charts:
Stocks - RTH: 390 mins/day
Stocks - ETH: 780 mins/day
VIX: 855 mins/day
Futures: 1440 mins/day
This ensures the MA reflects 5 full trading days, regardless of session irregularities or bar interval.
📌 Why Use This Indicator?
Most MAs misrepresent trend direction on intraday charts because they assume static daily bar counts. This tool corrects that, then adds slope-based coloring to give you a fast, visual read on short-term momentum. Whether you’re swing trading SPY, scalping VIX, or position trading futures, this indicator keeps your view aligned with how institutions see moving averages across timeframes.
🔧 Best For:
VIX & volatility traders
Short-term SPY/SPX traders
Swing traders who value clean setups
Anyone wanting a true 5-day trend anchor on any chart
This indicator plots a dynamic 5-period moving average that adapts intelligently to your chart's timeframe and product type — giving you a clean, slope-sensitive visual edge across intraday, daily, and weekly views.
✅ Key Features:
📈 Dynamic MA Length Scaling:
On intraday timeframes, the MA adjusts for your selected market session (RTH, ETH, VIX, or Futures), calculating a true 5-day average based on actual session length — not just a flat bar count.
🔄 Automatic Timeframe Detection:
Daily Chart: Uses standard 5DMA or 5EMA.
Weekly Chart: Applies a true 5-week MA.
Intraday Charts: Converts 5 days into bar-length equivalent dynamically.
🎨 Color-Coded Slope Logic:
Green = Rising MA (bullish slope)
Red = Falling MA (bearish slope)
Neutral slope = previous color held for visual continuity
No more guessing — direction is instantly clear.
⚠️ Built-In Slope Flip Alerts:
Set alerts when the slope of the MA turns up or down. Ideal for timing pullback entries or exits across any product.
⚙️ Session Settings for Proper Scaling:
Choose your product's market structure to ensure accurate 5-day conversion on intraday charts:
Stocks - RTH: 390 mins/day
Stocks - ETH: 780 mins/day
VIX: 855 mins/day
Futures: 1440 mins/day
This ensures the MA reflects 5 full trading days, regardless of session irregularities or bar interval.
📌 Why Use This Indicator?
Most MAs misrepresent trend direction on intraday charts because they assume static daily bar counts. This tool corrects that, then adds slope-based coloring to give you a fast, visual read on short-term momentum. Whether you’re swing trading SPY, scalping VIX, or position trading futures, this indicator keeps your view aligned with how institutions see moving averages across timeframes.
🔧 Best For:
VIX & volatility traders
Short-term SPY/SPX traders
Swing traders who value clean setups
Anyone wanting a true 5-day trend anchor on any chart
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Regards,
Dan
Dan
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Regards,
Dan
Dan
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.