• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

Smoothed Moving Average For ThinkOrSwim

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).
 

kingkunta

New member
Think or swim has this study, im just looking for a way to make it like trading views, where it changes colors. Thanks in advance!
This study already exists in Thinkorswim. But the trading view version changes color. Im wondering if anyone is able to add the changing color function to the thinkorswim one.
Here are the pictures in comparison. The code is above, Hopefully this helps

Code:
//@version=2
//WELLES WILDER SMOOTHING / WILDER'S MOVING AVERAGE
//author: @fr3762 KIVANÇ
study("WILD MA", overlay=true)

malength = input(14, "length", minval=1)
wild=nz(wild[1])+(close-nz(wild[1]))/malength

col1= wild>wild[1]
col3= wild<wild[1]
color = col1 ? green : col3 ? red : yellow

plot(wild, color=color, linewidth=2, title="WILD")
 
Last edited by a moderator:

Fluideng

Member
@MerryDay @rad14733 as I mentioned in my post, this study already exits in Thinkorswim. But the trading view version changes color. Im wondering if anyone is able to add the changing color function to the thinkorswim one.



Here are the pictures in comparison. The code is above, Hopefully this helps
Try this.
Code:
#WildersSmoothing_Colored

input price = close;
input length = 14;
input displace = 0;

plot WS = WildersAverage(price[-displace], length);

WS.setDefaultColor(getColor(0));
WS.AssignValueColor(if close>=WS then Color.Green else Color.Red);
 

rad14733

Well-known member
VIP
Crazy as it sounds, I just added the TOS WildersSmoothing MA Study, with its default setting of 14 (Gray), onto one of my charts that already has a 34EMA (Yellow) on it and they are stunningly similar...

5EACVHk.png
 

Similar threads

Top