Variable moving average standard deviation?

A

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

BenTen

Administrative
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.
 
A

arod49

New member
I keep typing VariableMA in the Vixfix but its not working
 
horserider

horserider

Well-known member
VIP
@arod49 You need to define variableMA first then use VMA value in the BB code.
 
BenTen

BenTen

Administrative
Staff
VIP
@arod49 post the entire code of what you’re trying to get done.
 
horserider

horserider

Well-known member
VIP
USe the ToS variable MA study. So the study must first define the variable MA and then you can use that value for the center of the bands.
 

Similar threads

Top