ROC in Bollinger Bands Thickness For ThinkOrSwim

BigliBigli

New member
Hello all

I've been in this forum for the past couple of months and learned a lot from you guys.

I've been using the following indicator/strategy for the past couple of weeks and it was good for me, so I thought I share it with you and get your help in improving it.
The idea is simple, it came from Balanced BB Breakout and the fact that Bolinger band thickness squeezes before a break. I put the following simple script together that calculates the rate of change of BB (backward-looking) and if this rate of change passes a defined (user input) threshold, signals.

I used this on daily charts and the strategy is simple, enter one cent above(below) the high (low) for long(short). My target is usually one ATR for a quick scalp but it can be modified according to your personal strategy.

I love to keep my codes simple, once the signal is generated (green for long and red for short) the price on the vertical line indicates the entry, and the following bubble shows the target based on ATR.

The threshold and moving average length can be adjusted and the default numbers are the ones that worked best for me.


Rich (BB code):
#
# Rate of change in BB thickness
#
# Author: Ali Mohtat (BigliBigli)
# Version: 2021-04-15 V1
#
# This code is licensed (as applicable) under the GPL v3
#
# ----------------------

declare lower;

def lookback = 1.0;
input sma_length = 9;
input Target_ATR_coeff = 1.0;
input cross_over = 1.0;

def percent_bb = (BollingerBands().UpperBand - BollingerBands().LowerBand) / BollingerBands();


def slope_1 = 100 * (3 * percent_bb - 4 * percent_bb[lookback] + percent_bb[2 * lookback]) / (2 * lookback);

plot average_slope_1 = SimpleMovingAvg(slope_1, sma_length);
plot zero_line = 0;

def macd_diff = MACD() - MACD()[1];
def Long_signal = AbsValue(average_slope_1) crosses cross_over and macd_diff>0;
def Short_signal = AbsValue(average_slope_1) crosses cross_over and macd_diff<0;
AddVerticalLine(Long_signal, high + 0.01,color.GREEN);
AddChartBubble ( Long_signal, 0, high + 0.01 + Target_ATR_coeff * ATR(), Color.GREEN, yes);

AddVerticalLine(Short_signal, low - 0.01,color.RED);
AddChartBubble (Short_signal, 0, low - 0.01 - Target_ATR_coeff * ATR(), Color.RED, NO);

gVtBocu.png


Rnb8pjw.png


RhpyfSX.png


This is a developing indicator, please let me know what you think and I would improve it with your help.
one last thing, be careful with the threshold adjustment! The default values work well with stocks (if you want to move to futures, it should be a much smaller value close to zero). for example, on a 5 min ES, the threshold is about 0.01 as:

wH9ZvoK.png
 
Last edited:
Very clever code! This seems great for selling .16 delta options with the trend This seems to catch continued trend or at worst consolidation. Allowing theta decay to pay up even if we get direction wrong. Thanks for sharing this. I was trying to do a similar thing to Mobius TMO indicator but had no luck. this is really cool!
 
Very clever code! This seems great for selling .16 delta options with the trend This seems to catch continued trend or at worst consolidation. Allowing theta decay to pay up even if we get direction wrong. Thanks for sharing this. I was trying to do a similar thing to Mobius TMO indicator but had no luck. this is really cool!
Agree, thanks for your feedback. I usually use this with Hull Moving Average Turning Points and Concavity (2nd Derivatives) and RSM Indicator for ThinkorSwim to adjust/confirm the trend/crossing. Give it a shot and you will get better results.
 
Hello all

I've been in this forum for the past couple of months and learned a lot from you guys.

I've been using the following indicator/strategy for the past couple of weeks and it was good for me, so I thought I share it with you and get your help in improving it.
The idea is simple, it came from Balanced BB Breakout and the fact that Bolinger band thickness squeezes before a break. I put the following simple script together that calculates the rate of change of BB (backward-looking) and if this rate of change passes a defined (user input) threshold, signals.

I used this on daily charts and the strategy is simple, enter one cent above(below) the high (low) for long(short). My target is usually one ATR for a quick scalp but it can be modified according to your personal strategy.

I love to keep my codes simple, once the signal is generated (green for long and red for short) the price on the vertical line indicates the entry, and the following bubble shows the target based on ATR.

The threshold and moving average length can be adjusted and the default numbers are the ones that worked best for me.


Rich (BB code):
#
# Rate of change in BB thickness
#
# Author: Ali Mohtat (BigliBigli)
# Version: 2021-04-15 V1
#
# This code is licensed (as applicable) under the GPL v3
#
# ----------------------

declare lower;

def lookback = 1.0;
input sma_length = 9;
input Target_ATR_coeff = 1.0;
input cross_over = 1.0;

def percent_bb = (BollingerBands().UpperBand - BollingerBands().LowerBand) / BollingerBands();


def slope_1 = 100 * (3 * percent_bb - 4 * percent_bb[lookback] + percent_bb[2 * lookback]) / (2 * lookback);

plot average_slope_1 = SimpleMovingAvg(slope_1, sma_length);
plot zero_line = 0;

def macd_diff = MACD() - MACD()[1];
def Long_signal = AbsValue(average_slope_1) crosses cross_over and macd_diff>0;
def Short_signal = AbsValue(average_slope_1) crosses cross_over and macd_diff<0;
AddVerticalLine(Long_signal, high + 0.01,color.GREEN);
AddChartBubble ( Long_signal, 0, high + 0.01 + Target_ATR_coeff * ATR(), Color.GREEN, yes);

AddVerticalLine(Short_signal, low - 0.01,color.RED);
AddChartBubble (Short_signal, 0, low - 0.01 - Target_ATR_coeff * ATR(), Color.RED, NO);

gVtBocu.png


Rnb8pjw.png


RhpyfSX.png


This is a developing indicator, please let me know what you think and I would improve it with your help.
one last thing, be careful with the threshold adjustment! The default values work well with stocks (if you want to move to futures, it should be a much smaller value close to zero). for example, on a 5 min ES, the threshold is about 0.01 as:

wH9ZvoK.png
Very cool code, appreciate your work! I put it on my chart for /RTY (tick) (Russel Futures) and while I do get the slope line there are no vertical signal lines. I was hoping you'd be able to tell me what I'm doing wrong. My settings are sma length = 9, target atr coeff = 1.0, cross over = 0.1. Thanks again!
 
Very cool code, appreciate your work! I put it on my chart for /RTY (tick) (Russel Futures) and while I do get the slope line there are no vertical signal lines. I was hoping you'd be able to tell me what I'm doing wrong. My settings are sma length = 9, target atr coeff = 1.0, cross over = 0.1. Thanks again!
Hi Splinter

I've tried this for /RTY and you only have to change your cross over to 0.01. This indicator needs a little experimenting to determine the best coefficients for the specific vessel. You can also change the sma length depending on the number of signals you want to get (the larger the sma, the fewer signals you'll get).
Following are results on /RTY 5 min and 1 min.
Let me know if you have any questions.

4CELdva.png

4CELdva.png
 
Hi Splinter

I've tried this for /RTY and you only have to change your cross over to 0.01. This indicator needs a little experimenting to determine the best coefficients for the specific vessel. You can also change the sma length depending on the number of signals you want to get (the larger the sma, the fewer signals you'll get).
Following are results on /RTY 5 min and 1 min.
Let me know if you have any questions.

4CELdva.png

4CELdva.png
Ah! got it. When I was trying to change it in the dialogue box for the script it went to a negative number....I changed it in the source code and all is well. Thanks so much for your prompt reply!
 
Agree, thanks for your feedback. I usually use this with Hull Moving Average Turning Points and Concavity (2nd Derivatives) and RSM Indicator for ThinkorSwim to adjust/confirm the trend/crossing. Give it a shot and you will get better results.
I will check all those out alongside with your indicator.

I want you to look at this current beta version of a divergence momentum indicator I am working on. I was originally trying to compare the rate of change between upwards momentum and downwards momentum to try to highlight up moves that look strong but aren't and down moves that look strong but aren't. Every color is a buying opportunity except Bright red. Dark red shows what would normally look like a strong down move but isn't considered yet. If you take a look at my code you can see how I came up with my solution. Yours is much more sophisticated IMO.

(removed beta code)

I wonder if using your code with mine will yield better results. Or even implementing your rate of change inside my momo indicator and replacing my method

EDIT:

here is your code and my momo code combined! Amazing results ( the bottom indicator is not needed anymore just the top indicator with colored bars) . (removed beta code)

I can not thank you enough for this line of code you have provided! I think my indicator maybe ready to have it's separate post now after I clean the code up. would you be okay with my including you in that post?
 
Last edited:
I will check all those out alongside with your indicator.

I want you to look at this current beta version of a divergence momentum indicator I am working on. I was originally trying to compare the rate of change between upwards momentum and downwards momentum to try to highlight up moves that look strong but aren't and down moves that look strong but aren't. Every color is a buying opportunity except Bright red. Dark red shows what would normally look like a strong down move but isn't considered yet. If you take a look at my code you can see how I came up with my solution. Yours is much more sophisticated IMO.

http://tos.mx/ZkgBahC

I wonder if using your code with mine will yield better results. Or even implementing your rate of change inside my momo indicator and replacing my method

EDIT:

here is your code and my momo code combined! Amazing results. http://tos.mx/Ie1fCE5

I can not thank you enough for this line of code you have provided! I think my indicator maybe ready to have it's separate post now after I clean the code up. would you be okay with my including you in that post?

I will check all those out alongside with your indicator.

I want you to look at this current beta version of a divergence momentum indicator I am working on. I was originally trying to compare the rate of change between upwards momentum and downwards momentum to try to highlight up moves that look strong but aren't and down moves that look strong but aren't. Every color is a buying opportunity except Bright red. Dark red shows what would normally look like a strong down move but isn't considered yet. If you take a look at my code you can see how I came up with my solution. Yours is much more sophisticated IMO.

http://tos.mx/ZkgBahC

I wonder if using your code with mine will yield better results. Or even implementing your rate of change inside my momo indicator and replacing my method

EDIT:

here is your code and my momo code combined! Amazing results ( the bottom indicator is not needed anymore just the top indicator with colored bars) . http://tos.mx/Ie1fCE5

I can not thank you enough for this line of code you have provided! I think my indicator maybe ready to have it's separate post now after I clean the code up. would you be okay with my including you in that post?
That looks amazing, I'll play with it for a while and let you know the results.
Of course, I'll be glad to!
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
311 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