Variable moving average standard deviation?

arod49

New member
I was wondering if its possible to add standard deviation to a variable moving average to create something similar to Bollinger Bands?
 

BenTen

Administrative
Staff member
Staff
VIP
Sure, you can take the following code from this script and replace VixFix with whatever variable you want.

Code:
# BollingerBands code

input ShowBollingerBands = No;
input displace = 0;
input BBlength = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def sDev = stdev(data = VixFix[-displace], length = BBlength);
def MidLine = MovingAverage(averageType, data = VixFix[-displace], length = BBlength);

def LowerBand = MidLine + num_Dev_Dn * sDev;
def UpperBand = MidLine + num_Dev_Up * sDev;
plot LB = if ShowBollingerBands then LowerBand else Double.NaN;
plot UB = if ShowBollingerBands then UpperBand else Double.NaN;
LB.SetDefaultColor(GetColor(0));
UB.SetDefaultColor(GetColor(5));

P.S: next time please post your question in the Questions forum.
 

Brain Monkey

New member
On think or swim, Im looking for a study that charts not just the simple moving average but also draws a channel around the SMA of 1 standard deviation away from the SMA. Is there a study for that?
 

rad14733

Well-known member
VIP
On think or swim, Im looking for a study that charts not just the simple moving average but also draws a channel around the SMA of 1 standard deviation away from the SMA. Is there a study for that?
Do a search for "sma deviation channels" and you'll find more than a few topics... Several studies exist... We shouldn't be expected to search for you and hand over the links...
 

Brain Monkey

New member
First of all, no one is asking You for anything. A simple, "Their called Bollinger bands, a study already exists." or if you simply don't know what you are talking about, don't have to say anything. I don't know what they are because I don't use indicators like that, but for you to come on here acting like you do and then to be smug about, I don't don't even know what to say about that. "SMA deviation channels" isn't a thing. If answering questions on a forum for answering questions is an issue what are you even doing here?
 

rad14733

Well-known member
VIP
@Brain Monkey I'm sorry you feel the way you do but the honest truth is that far too many members come asking questions and expecting to be hand fed rather than doing any actual research for themselves... Whether or not you fall into that category is subjective... It can be literally exhausting to come here throughout the day and see it happen over and over again... If you spent the time here that a few of us do then you would understand... I feel that a timely response to members questions is paramount, even if it isn't the answer they want...
 
Top