Rate of change in Bollinger bands thickness

BigliBigli

New member
VIP
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);``````

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:

Last edited:

young_and_dumb

New member
VIP
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!

BigliBigli

New member
VIP
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.

Splinter

New member
VIP
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);``````

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:

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!

BigliBigli

New member
VIP
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.

Splinter

New member
VIP
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.

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!

young_and_dumb

New member
VIP
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:

BigliBigli

New member
VIP
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!

young_and_dumb

New member
VIP
I'll PM you and share some stuff I have along the same premise. Maybe we can cook something up and make a new post supporting it.

young_and_dumb

New member
VIP
Actually - I am unsure of how to private message on this site. Can't seem to figure it out. is there a way?

BigliBigli

New member
VIP
Actually - I am unsure of how to private message on this site. Can't seem to figure it out. is there a way?
I don't think there is a private message option available in this forum. For now, we can use email as a sub.

Last edited:

Well-known member
VIP
I don't think there is a private message option available in this forum. For now, we can use email as a sub.

Nope... No Private Messaging here... Most just join the Discord Channel and DM each other there... I do one-on-one support there often...

young_and_dumb

New member
VIP
Nope... No Private Messaging here... Most just join the Discord Channel and DM each other there... I do one-on-one support there often...
We sorted it out for now - but @rad14733 if you are interested with what I shared let me know and I can figure out to get on discord and send it your way. I just didn't want to muck the thread up with a bunch of side rants off topic.

BigliBigli

New member
VIP
We sorted it out for now - but @rad14733 if you are interested with what I shared let me know and I can figure out to get on discord and send it your way. I just didn't want to muck the thread up with a bunch of side rants off topic.
You are right, we can definitely use insights from experienced members such as @rad14733

Ilya

New member
VIP
I have been working on similar, combining it also with change in angle. If you want input I am willing to share

BigliBigli

New member
VIP
I have been working on similar, combining it also with change in angle. If you want input I am willing to share
That sounds great Ilya, any inputs are welcome.

young_and_dumb

New member
VIP
@Ilya and @BigliBigli I just signed up for VIP so I have a little more freedoms.

If you both join the discord private channel We can all connect through there and create a private chat. I just joined you should be able to find the same icon/user there.

Ilya

New member
VIP
I am willing, how do I join?