Tradingview places a limit on the number of indicators you can place on a chart. If you are on a free or lower paid plan, this means you need to choose your indicators wisely. Users on the free tier are limited to just three indicators and even the first paid pro plan is limited to five. Don’t get me wrong, I am not an indicator junkie but for those of us who like to keep an eye on the 100 and 200 moving average levels, we are going to find our quota used up quickly. Consequently, I decided to develop a simple “multi” SMA indicator so that multiple SMA’s can be monitored whilst only using a single indicator slot.
About the Indicator
Although the indicator does nothing more than it says on the tin, There are a couple of points worth mentioning:
- The indicator will let you view up to 4 SMA’s
- You can set the period for each SMA independently
- You can set the resolution for each SMA independently (So you can see the see the daily SMA level when on the 15-minute chart for example)
- Each SMA can be turned on/off independently to avoid clutter.
The Multiple SMA’s Indicator Code
study("Multi SMA's", overlay=true)
//Get SMA Values
smaA = input(title='SMA1', type=integer, minval=1, step=1, defval=20)
smaB = input(title='SMA2', type=integer, minval=1, step=1, defval=50)
smaC = input(title='SMA3', type=integer, minval=1, step=1, defval=100)
smaD = input(title='SMA4', type=integer, minval=1, step=1, defval=200)
resA = input(title='SMA1 Resolution', type=resolution, defval="D")
resB = input(title='SMA2 Resolution', type=resolution, defval="D")
resC = input(title='SMA3 Resolution', type=resolution, defval="D")
resD = input(title='SMA4 Resolution', type=resolution, defval="D")
smaAswitch = input(title="SMA 1 On/Off", type=bool, defval=true)
smaBswitch = input(title="SMA 2 On/Off", type=bool, defval=true)
smaCswitch = input(title="SMA 3 On/Off", type=bool, defval=true)
smaDswitch = input(title="SMA 4 On/Off", type=bool, defval=true)
dataA = security(tickerid, resA, sma(close, smaA))
dataB = security(tickerid, resB, sma(close, smaB))
dataC = security(tickerid, resC, sma(close, smaC))
dataD = security(tickerid, resD, sma(close, smaD))
plot(smaAswitch ? dataA : na, color=aqua)
plot(smaBswitch ? dataB : na, color=orange)
plot(smaCswitch ? dataC : na, color=green, linewidth=2)
plot(smaDswitch ? dataD : na, color=red, linewidth=2)
On the charts:
I am sure you know what to expect with an SMA but here is what the indicator looks like on the charts:
Mixing daily and minute resolutions
The following screenshot mixes daily and 15-minute 50 and 200 SMA’s on the 15-minute chart.
And there we have it… Not much to it. I hope you find it useful!
Find This Post Useful?
If this post saved you time and effort, please consider support the site! There are many ways to support us and some won’t even cost you a penny.
Backtest Rookies is a registered with Brave publisher!
Brave users can drop us a tip.
Alternatively, support us by switching to Brave using this referral link and we will receive some BAT!
Enjoying the content and thinking of subscribing to Tradingview? Support this site by clicking the referral link before you sign up!