This moving average script displays the chosen 5 daily moving averages on intraday (minute) charts. It automatically adjusts the intervals to show the proper moving averages.
In a day there are 375 trading minutes from 9:15 AM to 3:30PM in Indian market. In 5 days there are 1875 minutes. For other markets adjust this data accordingly.
If 5DMA is chosen on a five minute chart the moving average will use 375 interval values (1875/5 = 375) of 5minute chart to calculate moving average. Same 5DMA on 25minute chart will use 75 interval values (1875/25 = 75).
On a 1minute chart the 5DMA plot will use 1875 interval values to arrive at the moving average. Since tradingview only allows 5000 intervals to lookback, if a particular daily moving average on intraday chart needs more than 5000 candle data it won't be shown. E.g 200DMA on 5minute chart needs 15000 candles data to plot a correct 200DMA line. Anything less than that would give incorrect moving average and hence it won't be shown on the chart.
MA crossover for the first two MAs is provided. If you want to use that option, make sure you give the moving averages in the correct order.
You can enhance this script and use it in any way you please as long as you make it opensource on TradingView. Feedback and improvement suggestions are welcome.
Special thanks to JohnMuchow for his moving averages script for all timeframes.