OPEN-SOURCE SCRIPT

Custom Moving Averages

72
//version=6
indicator(title="Custom Moving Averages", overlay=true)

// Daily Moving Averages
ma10d = ta.sma(close, 10) // 10-day moving average
ma21d = ta.sma(close, 21) // 21-day moving average

// Weekly Moving Averages (Assuming 5 trading days per week)
ma10w = ta.sma(close, 50) // 10-week moving average (10 * 5)
ma30w = ta.sma(close, 150) // 30-week moving average (30 * 5)

// Plot the Moving Averages
plot(ma10d, color=color.blue, title="10-Day MA", linewidth=2)
plot(ma21d, color=color.green, title="21-Day MA", linewidth=2)
plot(ma10w, color=color.red, title="10-Week MA", linewidth=2)
plot(ma30w, color=color.orange, title="30-Week MA", linewidth=2)

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.