OPEN-SOURCE SCRIPT

Daily Moving Average for Intraday Timeframes

Updated
This indicator provides a dynamic tool for visualizing the Daily Moving Average (DMA) on intraday timeframes.

It allows you to analyze how the price behaves in relation to the daily moving average in timeframes from 1 minute up to 1 day.


KEY FEATURES

DMA on Intraday timeframes only: This indicator is designed to work exclusively on intraday charts with timeframes between 1 minute and 1 day. It will not function on tick, second-based, or daily-and-above charts.

Color-Coded Zones for Trend Identification:
  • Green Zone: The price is above a rising DMA, signaling a bullish momentum.
  • Red Zone: The price is below a falling DMA, signaling a bearish momentum.
  • Yellow Zone: Signaling uncertainty or mixed conditions, where either the price is above a falling DMA or below a rising/flat DMA.


Configurable DMA Period: You can adjust the number of days over which the DMA is calculated (default is 5 days). This can be customized based on your trading strategy or market preferences.

24/7 Market Option: For assets that trade continuously (e.g., cryptocurrencies), activate the "Is trading 24/7?" setting to ensure accurate calculations.



WHAT IS THE DMA AND WHY USE IT INTRADAY?

The Daily Moving Average is a Simple Moving Average indicator used to smooth out price fluctuations over a specified period (in days) and reveal the underlying trend.

Typically, a SMA takes price value for the current timeframe and reveal the trend for this timeframe. It gives you the average price for the last N candles for the given timeframe.

But what makes the Intraday DMA interesting is that it shows the underlying trend of the Daily timeframe on a chart set on a shorter timeframe. This helps to align intraday trades with broader market movements.

HOW IS THE DMA CALCULATED?

If we are to build a N-day Daily Moving Average using a Simple Moving Average, we need to take the amount of candles A needed in that timeframe to account for a period of a day and multiply it by the number of days N of the desired DMA.

So for instance, let say we want to compute the 5-Day DMA on the 10 minute timeframe :
  • In the 10 minute timeframe there are 39 candles in a day in the regular session.
  • We would take the 39 candles per day and then multiply that by 5 days. 39 x 5 = 195.
  • So a 5-day moving average is represented by a simple moving average with a period of 195 when looking at a 10 minute timeframe.


So for each period, to create a 5-day DMA, you would have to set the period of your simple moving average like so :
- 195 minutes = 10 period
- 130 minutes = 15 period
- 65 minutes = 30 period
- 30 minutes = 65 period
- 15 minutes = 130 period
- 10 minutes = 195 period
- 5 minutes = 390 period
and so on.

This indicator attempts to do this calculation for you on any intraday timeframe and whatever the period you want to use is for your DMA. You can create a 10-day moving average, a 30-day moving average, etc.
Release Notes
This indicator provides a dynamic tool for visualizing the Daily Moving Average (DMA) on intraday timeframes.

It allows you to analyze how the price behaves in relation to the daily moving average in timeframes from 1 minute up to 1 day.


KEY FEATURES

DMA on Intraday timeframes only: This indicator is designed to work exclusively on intraday charts with timeframes between 1 minute and 1 day. It will not function on tick, second-based, or daily-and-above charts.

Color-Coded Zones for Trend Identification:
  • Green Zone: The price is above a rising DMA, signaling a bullish momentum.
  • Red Zone: The price is below a falling DMA, signaling a bearish momentum.
  • Yellow Zone: Signaling uncertainty or mixed conditions, where either the price is above a falling DMA or below a rising/flat DMA.



Configurable DMA Period: You can adjust the number of days over which the DMA is calculated (default is 5 days). This can be customized based on your trading strategy or market preferences.

Crypto and Futures support: For assets that trade continuously (e.g., cryptocurrencies or US Futures), you can use the "Session type" setting to ensure accurate calculations.



WHAT IS THE DMA AND WHY USE IT INTRADAY?

The Daily Moving Average is a Simple Moving Average indicator used to smooth out price fluctuations over a specified period (in days) and reveal the underlying trend.

Typically, a SMA takes price value for the current timeframe and reveal the trend for this timeframe. It gives you the average price for the last N candles for the given timeframe.

But what makes the Intraday DMA interesting is that it shows the underlying trend of the Daily timeframe on a chart set on a shorter timeframe. This helps to align intraday trades with broader market movements.

HOW IS THE DMA CALCULATED?

If we are to build a N-day Daily Moving Average using a Simple Moving Average, we need to take the amount of candles A needed in that timeframe to account for a period of a day and multiply it by the number of days N of the desired DMA.

So for instance, let say we want to compute the 5-Day DMA on the 10 minute timeframe :
In the 10 minute timeframe there are 39 candles in a day in the regular session.
We would take the 39 candles per day and then multiply that by 5 days. 39 x 5 = 195.
So a 5-day moving average is represented by a simple moving average with a period of 195 when looking at a 10 minute timeframe.

So for each period, to create a 5-day DMA, you would have to set the period of your simple moving average like so :
- 195 minutes = 10 period
- 130 minutes = 15 period
- 65 minutes = 30 period
- 30 minutes = 65 period
- 15 minutes = 130 period
- 10 minutes = 195 period
- 5 minutes = 390 period
and so on.

This indicator attempts to do this calculation for you on any intraday timeframe and whatever the period you want to use is for your DMA. You can create a 10-day moving average, a 30-day moving average, etc.
dailymovingaverageDMAintradayMoving AveragesSimple Moving Average (SMA)Trend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer