Dual Bollinger Bands For ThinkOrSwim

henry1224

Expert
VIP
Lifetime
Code:
input price = close;
input displace = 0;
input length1 = 20;
input length2 = 60;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev1 = stdev(data = price[-displace], length = length1);
def sDev2 = stdev(data = price[-displace], length = length2);
plot MidLine1 = MovingAverage(averageType, data = price[-displace], length = length1);
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
plot MidLine2 = MovingAverage(averageType, data = price[-displace], length = length2);
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Code:
input price = close;
input displace = 0;
input length1 = 20;
input length2 = 60;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev1 = stdev(data = price[-displace], length = length1);
def sDev2 = stdev(data = price[-displace], length = length2);
plot MidLine1 = MovingAverage(averageType, data = price[-displace], length = length1);
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
plot MidLine2 = MovingAverage(averageType, data = price[-displace], length = length2);
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);
Question how can I change the 20 moving average or 60 moving average with the study of tenken from the ichimoku cloud and get the bollinger band so basically Bollinger band made of tenken
 
Last edited:
Question how can I change the 20 moving average or 60 moving average with the study of tenken from the ichimoku cloud and get the bollinger band so basically Bollinger band made of tenken
You would have to add a Standard Deviation to the tenken also you would have to subtract a Standard Deviation from the tenken
 
can you show me or make a bollinger band just like you have now but made with tenken?
Here is the Tenkan Bands Dual
Code:
input price = close;
input displace = 0;
input length1 = 9;
input length2 = 27;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev1 = stdev(data = price[-displace], length = length1);
def sDev2 = stdev(data = price[-displace], length = length2);
plot MidLine1 = (Highest(high, Length1) + Lowest(low, Length1)) / 2;
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
plot MidLine2 = (Highest(high, Length2) + Lowest(low, Length2)) / 2;
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);
 
Here is the Tenkan Bands Dual
Code:
input price = close;
input displace = 0;
input length1 = 9;
input length2 = 27;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev1 = stdev(data = price[-displace], length = length1);
def sDev2 = stdev(data = price[-displace], length = length2);
plot MidLine1 = (Highest(high, Length1) + Lowest(low, Length1)) / 2;
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
plot MidLine2 = (Highest(high, Length2) + Lowest(low, Length2)) / 2;
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);
Thank you!
 
Here is the Tenkan Bands Dual
Code:
input price = close;
input displace = 0;
input length1 = 9;
input length2 = 27;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev1 = stdev(data = price[-displace], length = length1);
def sDev2 = stdev(data = price[-displace], length = length2);
plot MidLine1 = (Highest(high, Length1) + Lowest(low, Length1)) / 2;
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
plot MidLine2 = (Highest(high, Length2) + Lowest(low, Length2)) / 2;
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);
I think looks really good you might want to add the name to

Dual Bollinger Bands with tenkan​

Thank you again!
 
Here is the Tenkan Bands Dual
Code:
input price = close;
input displace = 0;
input length1 = 9;
input length2 = 27;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev1 = stdev(data = price[-displace], length = length1);
def sDev2 = stdev(data = price[-displace], length = length2);
plot MidLine1 = (Highest(high, Length1) + Lowest(low, Length1)) / 2;
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
plot MidLine2 = (Highest(high, Length2) + Lowest(low, Length2)) / 2;
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);
Want to find out if there is a way to add the volume study along with these bands so it takes the volume based off the middle line especially with the tenken indicator that you did with the bands
 
Here is Dual Bollinger Bands with Volume added MA,
Code:
input price = close;
input displace = 0;
input length1 = 20;
input length2 = 60;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def A = MovingAverage(averageType, data = Volume*Price[-displace], length = length1);
def B = MovingAverage(averageType, data = Volume[-displace], length = length1);
plot MidLine1 = A/B;
def sDev1 = stdev(data = A/B[-displace], length = length1);
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
def A2 = MovingAverage(averageType, data = Volume*Price[-displace], length = length2);
def B2 = MovingAverage(averageType, data = Volume[-displace], length = length2);
plot MidLine2 = A2/B2;

def sDev2 = stdev(data = A2/B2[-displace], length = length2);
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);


I found that using volume , distorts the bands and makes them untradeable IMO.
 
Here is Dual Bollinger Bands with Volume added MA,
Code:
input price = close;
input displace = 0;
input length1 = 20;
input length2 = 60;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def A = MovingAverage(averageType, data = Volume*Price[-displace], length = length1);
def B = MovingAverage(averageType, data = Volume[-displace], length = length1);
plot MidLine1 = A/B;
def sDev1 = stdev(data = A/B[-displace], length = length1);
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
def A2 = MovingAverage(averageType, data = Volume*Price[-displace], length = length2);
def B2 = MovingAverage(averageType, data = Volume[-displace], length = length2);
plot MidLine2 = A2/B2;

def sDev2 = stdev(data = A2/B2[-displace], length = length2);
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);


I found that using volume , distorts the bands and makes them untradeable IMO.
Thank you!
I will take a look at it!
 
Here is Dual Bollinger Bands with Volume added MA,
Code:
input price = close;
input displace = 0;
input length1 = 20;
input length2 = 60;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def A = MovingAverage(averageType, data = Volume*Price[-displace], length = length1);
def B = MovingAverage(averageType, data = Volume[-displace], length = length1);
plot MidLine1 = A/B;
def sDev1 = stdev(data = A/B[-displace], length = length1);
plot LowerBand1 = MidLine1 + num_Dev_Dn * sDev1;
plot UpperBand1 = MidLine1 + num_Dev_Up * sDev1;
LowerBand1.SetDefaultColor(Color.Yellow);
MidLine1.SetDefaultColor(Color.Yellow);
UpperBand1.SetDefaultColor(Color.Yellow);
def A2 = MovingAverage(averageType, data = Volume*Price[-displace], length = length2);
def B2 = MovingAverage(averageType, data = Volume[-displace], length = length2);
plot MidLine2 = A2/B2;

def sDev2 = stdev(data = A2/B2[-displace], length = length2);
plot LowerBand2 = MidLine2 + num_Dev_Dn * sDev2;
plot UpperBand2 = MidLine2 + num_Dev_Up * sDev2;
LowerBand2.SetDefaultColor(Color.Gray);
MidLine2.SetDefaultColor(Color.Gray);
UpperBand2.SetDefaultColor(Color.Gray);
AddCloud(UpperBand1, UpperBand2, Color.Yellow, Color.BLACK);
AddCloud(LowerBand1,LowerBand2, Color.BLACK, Color.Yellow);
def MXBand = Max(UpperBand1,Upperband2);
def MNBand = Min(LowerBand1,LowerBand2);
Input Arrows = no;
Input DotSize = 3;
#ARROWS
plot ArrowDown = if arrows and (Close Crosses below MXBand) then MXBand else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Yellow);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Close crosses above MNBand ) then MnBand else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Yellow);
ArrowUp.setLineWeight(dotsize);


I found that using volume , distorts the bands and makes them untradeable IMO.
You are right it doesn't work but thank you for making the change.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
254 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top