germanburrito
Active member
This is my version of the true center band indicator. you guys have been great to me. Improvements are encouraged and welcome.
Code:
input price = close;
input length = 40;
def displacement = (length);
def dPrice = price[displacement];
def tmp = if !IsNaN(dPrice) then Average(dPrice, AbsValue(length)) else tmp[1] + (tmp[1] - tmp
[2]);
def tmp1 = if !IsNaN(price) then tmp else Double.NaN;
plot Data = tmp1;
Data.SetDefaultColor(color.yellow );
def pct=100;
input width=50;
def d=width/pct;
def d1=2*d;
def d25=1.07*d;
def d2=1.15*d;
def d3=1.618*d;
def d4=.47*d;
def stdDeviation = Highestall("data" = AbsValue(tmp1 - price));
plot UpperLine = tmp1 + stdDeviation*d1;
plot LowerLine = tmp1 - stdDeviation*d1;
plot UpperLine1 = tmp1 + stdDeviation*d25;
plot LowerLine1 = tmp1 - stdDeviation*d2;
plot UpperLine2 = tmp1 + stdDeviation*d3;
plot LowerLine2 = tmp1 - stdDeviation*d3;
plot UpperLine4 = tmp1 + stdDeviation*d4;
plot LowerLine4 = tmp1 - stdDeviation*d4;
UpperLine.SetDefaultColor(color.Green);
UpperLine1.SetDefaultColor(color.cyan);
UpperLine2.SetDefaultColor(color.violet);
LowerLine.SetDefaultColor(color.white );
LowerLine1.SetDefaultColor(color.orange );
LowerLine2.SetDefaultColor(color.blue );
LowerLine4.SetDefaultColor(color.light_RED );
LowerLine4.SetDefaultColor(color.red );
data.setDefaultColor(color.YEllow);
upperline.SetLineWeight(2);
upperline1.SetLineWeight(2);
upperline2.SetLineWeight(2);
upperline4.SetLineWeight(2);
upperline.SetLineWeight(2);
lowerLine.setlineweight(2);
lowerLine1.setlineweight(2);
lowerLine2.setlineweight(2);
lowerLine4.setlineweight(2);
Data.setlineweight(2);
Attachments
Last edited by a moderator: