• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Convert smoothed moving average to ToS

Piper2808t

Member
2019 Donor
VIP
Can this be created in tos. its from trading view

Code:
study(title="Smoothed Moving Average", shorttitle="SMMA", overlay=true, resolution="")
len = input(7, minval=1, title="Length")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
plot(smma, color=color.red)
 

metaller

New member
VIP
Code:
# Smoothed Moving Average
# Converted to thinkorswim from trading view by Alex Ivanov aka Metaller
# Sep 21, 2020

input len = 7;
input src = close;

rec smma  = if (IsNaN(smma[1]) or smma[1]==0) then SimpleMovingAvg(src, len) else (smma[1] * (len - 1) + src) / len;

plot smma_plot = smma;
smma_plot.setDefaultColor(color.red);
 

metaller

New member
VIP
Interesting enough that SMMA provides virtually identical output as Wilders Moving Average :

Code:
input AvgType = AverageType.WILDERS;
input Price = close;
input Length = 7;
plot Data = MovingAverage(AvgType, Price, Length);

There is very small difference for first about 14 bars of chart (when len =7).
 

Similar threads

Top