input price = close;
input price1 = high;
input displace = 0;
input length = 200;
input length1 = 500;
input length2 = 100;
input length4 = 1000;
input atrmod=2;
def bn = barnumber();
def lastBar = highestall(if isnan(close) then 0 else bn);
def offset = bn - lastbar;
input averageType = AverageType.EXPONENTIAL;
input length3 = 9;
input showBreakoutSignals = no;
input length5 = 252;
input averageType1 = AverageType.WILDERS;
def atr = GetValue(ATR(length), offset);
# User Inputs
def Num_Dev_Dn = atr;
def Num_Dev_up = -atr;
plot top200AvgExp = ExpAverage(price[-displace], length) * 1.06;
plot top200AvgExpupBand = top200AvgExp + Num_Dev_Dn ;
top200AvgExpupBand.Hide();
plot top200AvgExplowBand = top200AvgExp + Num_Dev_up ;
top200AvgExplowBand.Hide();
AddCloud(top200AvgExp, top200AvgExpupBand, Color.WHITE, Color.WHITE);
AddCloud(top200AvgExp, top200AvgExplowBand, Color.WHITE, Color.WHITE);
top200AvgExp.SetDefaultColor(Color.MAGENTA);
######################################################################
plot top100AvgExp = ExpAverage(price[-displace], length2) * 1.08;
plot top100AvgExpupBand = top100AvgExp + Num_Dev_up ;
top100AvgExpupBand.Hide();
plot top100AvgExplowBand = top100AvgExp + Num_Dev_Dn ;
top100AvgExplowBand.Hide();
AddCloud(top100AvgExp, top100AvgExpupBand, Color.WHITE, Color.WHITE);
AddCloud(top100AvgExp, top100AvgExplowBand, Color.WHITE, Color.WHITE);
top100AvgExp.SetDefaultColor(Color.CYAN);
##################################################################
plot top500AvgExp = ExpAverage(price[-displace], length1) * 1.05;
top500AvgExp.SetDefaultColor(Color.YELLOW);
plot top500AvgExpupBand = top500AvgExp + Num_Dev_Dn ;
top500AvgExpupBand.Hide();
plot top500AvgExplowBand = top500AvgExp + Num_Dev_up ;
top500AvgExplowBand.Hide();
AddCloud(top500AvgExp, top500AvgExpupBand, Color.WHITE, Color.WHITE);
AddCloud(top500AvgExp, top500AvgExplowBand, Color.WHITE, Color.WHITE);
##########################################################################
plot top100AvgExp1 = ExpAverage(price[-displace], length2) * 1.19;
plot top100AvgExp1upBand = top100AvgExp1 + Num_Dev_Dn ;
top100AvgExp1upBand.Hide();
plot top100AvgExp1lowBand = top100AvgExp1 + Num_Dev_up ;
top100AvgExp1lowBand.Hide();
AddCloud(top100AvgExp1, top100AvgExp1upBand, Color.WHITE, Color.WHITE);
AddCloud(top100AvgExp1, top100AvgExp1lowBand, Color.WHITE, Color.WHITE);
top100AvgExp1.SetDefaultColor(Color.DARK_ORANGE);
def data = close;
def top200 = top200AvgExp - data;
plot dist200 = Round(top200 / top100AvgExp * 100, 2);