# WT_LB Short Name TV
#deviation_blue_wave
#MTF
declare lower;
input aggregationPeriod = AggregationPeriod.DAY;
def close = close (period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
input Channel_Length = 10; #10
input Average_Length = 21; #10
input over_bought_1 = 60;
input over_bought_2 = 53;
input over_sold_1 = -60;
input over_sold_2 = -53;
input show_bubbles = yes;
input show_sec_bbls = no;
input show_alerts = yes;
def ap = (High + Low + Close) / 3;
def esa = ExpAverage(ap, Channel_Length);
def d = ExpAverage(AbsValue(ap - esa), Channel_Length);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, Average_Length);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 3);
#def zero = 0;
def wt1_1 = wt1;
#wt1_1.SetDefaultColor(Color.GREEN);
def wt2_1 = wt2;
#wt2_1.SetDefaultColor(Color.RED);
#wt2_1.SetStyle(Curve.POINTS);
#plot wt3 = (wt1 - wt2);
#wt3.SetDefaultColor(Color.YELLOW);
#wt3.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#addcloud(wt3, 0, color.yellow);
#........................................
plot mean = inertiaAll((wt1+wt2)/2);
mean.setDefaultColor(color.cyan);
def dev1 = (stdevAll(wt1)+stdevAll(wt2))/2;
plot up = wt1_1+ dev1*2;
plot down = wt1_1- dev1*2;
plot avg2 =(up-down/up+down)-mean;
avg2.setDefaultColor(createcolor(250,10,10));
avg2.setDefaultColor(COLOR.PINK);
plot avg3 = 1.0* (up+down/up+down)-dev1;
avg3.setDefaultColor(color.white);
up.SetDefaultColor(Color.GREEN);
up.SetLineWeight(2);
down.SetDefaultColor(Color.RED);
down.SetLineWeight(2);
AddCloud(0, tci[0], createcolor(20,170,240), createcolor(20,170,240));
AddCloud(0, tci[0], createcolor(20,170,240), createcolor(20,170,240));
AddCloud(0, tci[0], createcolor(20,170,240), createcolor(20,170,240));
AddCloud(0, tci[0], createcolor(20,170,240), createcolor(20,170,240));
AddCloud(WT1, WT2, Color.white, Color.RED);
AddCloud(WT1, WT2, Color.white, Color.RED);
AddCloud(wt1, 0, CreateColor(40, 82, 248), CreateColor(30, 82, 248));
AddCloud(wt1, 0, CreateColor(40, 82, 248), CreateColor(30, 82, 248));
def W1 = if wt1 < wt2 then wt2 else wt1;
def W2 = if wt1 > wt2 then wt2 else wt2;
AddCloud(W1, W2, Color.WHITE, Color.WHITE);
AddCloud(W1, W2, Color.WHITE, Color.WHITE);
AddCloud(W1, W2, Color.WHITE, Color.WHITE);
AddCloud(W1, W2, Color.WHITE, Color.WHITE);
#END