True Center Band Indicator for ThinkorSwim

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);

 
Last edited by a moderator:

henry1224

Member
VIP
Hello German,

I have changed the colors of your bands to reflect Murrey Math colors, and I have added Clouds

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.Blue);
UpperLine1.SetDefaultColor(color.Red);
UpperLine2.SetDefaultColor(color.Yellow);
LowerLine.SetDefaultColor(color.Blue);
LowerLine1.SetDefaultColor(color.Red);
LowerLine2.SetDefaultColor(color.Yellow );
LowerLine4.SetDefaultColor(color.Green);
UpperLine4.SetDefaultColor(color.Green);
data.setDefaultColor(color.Blue);

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);

AddCloud(Upperline, Upperline2, Color.Pink, Color.Pink, no);
AddCloud(Upperline1, Upperline4, Color.pink, Color.Pink, no);
AddCloud(Lowerline4, Lowerline1, Color.LIme, Color.Lime, no);
AddCloud(Lowerline2, Lowerline, Color.Lime, Color.Lime, no);

Here is what I find that I don't like about this indicator, It bends with price. It doesn't have a backbone where price hits a firm resistance or support level. A trailing stop never backs down from price, it attacks price, till proven wrong. Just my opinion!
 

germanburrito

Active member
@henry1224 it does bend with price and also when resistnce hits the outter bands it will repaint, but its a cool idea, it pushes pass price into the future to see price levels and the inner bands usually are very true to price, it helps me dictate, its not bending entirely with current price but with pass price.

also i wouldnt use the blue band its too many bands, the bands are supost to be fibonacci ratios.
 

tenacity11

Active member
2019 Donor
Is there a scan that can be set up to scan for the lower band (white). I've found this to be quite interesting...
 

Similar threads

Top