Repaints B4 Balanced BB Breakout For ThinkOrSwim

Repaints
Status
Not open for further replies.
Here is a simple change you can make in the indicator script to make the Buy/Sell arrow only appear when all three signals (Balance of Power, Fibonacci Supertrend, and RSI IFT) are in a buy/sell state.

Find these lines:

Ruby:
def Strategy_Buy = BullBear_Buy and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BullBear_Sell and MACDBB_Sell and RSM_Sell;
def Strategy_BuySignal = Strategy_Buy and !Strategy_Buy[1];
def Strategy_SellSignal = Strategy_Sell and !Strategy_Sell[1];

and replace them with these:

Ruby:
def Strategy_Buy = BOP_Direction == 1 and FST_Direction == 1 and RSI_IFT_Direction == 1 and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BOP_Direction == -1 and FST_Direction == -1 and RSI_IFT_Direction == -1 and MACDBB_Sell and RSM_Sell;
def Strategy_BuySignal = Strategy_Buy and !Strategy_Buy[1];
def Strategy_SellSignal = Strategy_Sell and !Strategy_Sell[1];
 

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Here is a simple change you can make in the indicator script to make the Buy/Sell arrow only appear when all three signals (Balance of Power, Fibonacci Supertrend, and RSI IFT) are in a buy/sell state.

Find these lines:

Ruby:
def Strategy_Buy = BullBear_Buy and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BullBear_Sell and MACDBB_Sell and RSM_Sell;
def Strategy_BuySignal = Strategy_Buy and !Strategy_Buy[1];
def Strategy_SellSignal = Strategy_Sell and !Strategy_Sell[1];

and replace them with these:

Ruby:
def Strategy_Buy = BOP_Direction == 1 and FST_Direction == 1 and RSI_IFT_Direction == 1 and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BOP_Direction == -1 and FST_Direction == -1 and RSI_IFT_Direction == -1 and MACDBB_Sell and RSM_Sell;
def Strategy_BuySignal = Strategy_Buy and !Strategy_Buy[1];
def Strategy_SellSignal = Strategy_Sell and !Strategy_Sell[1];
Worked Pretty Slick.....
 
Mind sharing a screenshot of your chart labels? Thanks

Sure. Here are the RSM labels at the top left. The last one shows whether various EMAs (34, 55, and 89, I think) are stacked positive or negative (or gray for neither). It prevents my chart from looking like rainbow spaghetti.

See the back-to-back triple (and opposite!) strategy signals just before 8pm? The RSM labels and EMAs would have kept me from acting on either set of lower signals. If the labels are grayed out, there is no bull or bear direction on that timeframe for the RSM. I want RSM labels to be in agreement at the minimum from 60 min down to 5 min if I'm trading on a low timeframe. If any label 60 min or less is the wrong direction or greyed out, there is probably chop that I'm not seeing and the trend may not be strong enough to sustain the move I was looking for.

Hope that made sense!

 
Also is it possible to scan for the first red dot or green dot? That seems to be the main success of this method...when the dots appear, thats when the stock moves. The 3 strategies mentioned (i.e. Balance of Power, RSI_IFT and FibonacciSupertrend) seem to me to be more confirming the dots.

If all you want is to scan for MACD_BB dots, it's simple. You can save the scan in the sidebar and it'll update every 7-8 minutes if you want.
 
We are working on some solutions to most all the request, If I did not respond to you directly, it's not that I am avoiding you, but that I am busy trying to help others. Thank all of you for your questions and suggestions. We are working tirelessly to make this not just a lower indicator, but an entire trading system designed to help navigate these markets in a clear, precise manner.
 
We are working on some solutions to most all the request, If I did not respond to you directly, it's not that I am avoiding you, but that I am busy trying to help others. Thank all of you for your questions and suggestions. We are working tirelessly to make this not just a lower indicator, but an entire trading system designed to help navigate these markets in a clear, precise manner.
Thanks Chuck!!
 
Ruby:
Final Scan which includes everything :)

# Balanced BB Breakout Indicator
# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Author not responsible for errors or use of tool.
# v1.2 - Assembled by Chuck Edwards
# v2.0 - Barbaros - cleanup
# v2.1 - Barbaros - added RSI IFT, NumberOfShares, BB crossing options
# v2.2 - Barbaros - fixed PnL issues and removed intraDay filter
# v2.3 - Barbaros - changed input and variable names, RSM is re-done
# v2.4 - Barbaros - removed PnL, added strategy signal arrows and alerts,
#                   added Fibonacci SuperTrend, added unified bar color selection
# beta - Chuck    - added divergence and squeeze label, added squeeze alert
#        Barbaros - cleanup, changed divergance to text, show stoch labels all the time
#        Barbaros - added trend squeeze label for BB, added alerts for Stoch Scalper
#        Barbaros - added options to hide clouds and labels
#        Barbaros - changed trend and divergence colors and text to match
#        Barbaros - removed volume and keltner channel studies, unified squeeze
# v1.2 AspaTrader - Adapted new Indicator and added Fib series. TODO: MarketForecast
# v1.3 AspaTrader - Fixed issue with script complex or timeout
# V2.0 AspaTrade - Added signals for vertical Lines + Market Forecast + MACDBB + RSM Buy Signal + HMA Signal (55 MA) + BOP_Direction + Fibonacci Super Trend
### Market Forecast

def pIntermediate = MarketForecast().Intermediate;

def MF_SIGNAL = if pIntermediate >= 80 or  pIntermediate > pIntermediate[1] then 1 else
    if pIntermediate <= 20 or pIntermediate < pIntermediate[1] then 0 else -1;

### MACDBB

input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_Length = 25;
input MACDBB_BandLength = 15;
input MACDBB_NumDev = 1.0;

def MACDBB_Data = MACD(fastLength = MACDBB_FastLength, slowLength = MACDBB_SlowLength, MACDLength = MACDBB_Length);

def MACDBB_Upper = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;

def MACDBB_Lower = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;

def MACDBB_Midline = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                               Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).MidLine;
def MACDBB_Line = MACDBB_Data;
def MACDBB_SIGNAL =
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper or MACDBB_Line < MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper then 1
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower or MACDBB_Line > MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower then 0
    else -1;

input MACDBB_CrossFromAboveAlert = {default "Zero", "Lower", "Middle", "Upper"};
input MACDBB_CrossFromBelowAlert = {default "Zero", "Lower", "Middle", "Upper"};

def MACDBB_CrossFromAboveVal = if MACDBB_CrossFromAboveAlert == MACDBB_CrossFromAboveAlert.Lower then MACDBB_Lower
                               else if MACDBB_CrossFromAboveAlert == MACDBB_CrossFromAboveAlert.Upper then MACDBB_Upper
                              else 0;
def MACDBB_CrossFromBelowVal = if MACDBB_CrossFromBelowAlert == MACDBB_CrossFromBelowAlert.Lower then MACDBB_Lower
                               else if MACDBB_CrossFromBelowAlert == MACDBB_CrossFromBelowAlert.Upper then MACDBB_Upper
                               else 0;

def MACDBB_Buy = MACDBB_Data > MACDBB_Upper;
def MACDBB_Sell = MACDBB_Data <= MACDBB_Lower;

def MACDBB_OVERALL_SIGNAL = MACDBB_SIGNAL and MACDBB_Buy;

### RSI/STOCASTIC/MACD CONFLUENCE COMBO

def RSM_MACD_Diff = reference MACD("fast length" = 12, "slow length" = 26, "macd length" = 9).Diff;

def RSM_MACD_Diff_SIGNAL = if RSM_MACD_Diff >= 0 then
        if RSM_MACD_Diff > RSM_MACD_Diff[1] then 1 else -1
    else
        if RSM_MACD_Diff < RSM_MACD_Diff[1] then 0 else -1;

def RSM_RSI = reference RSI(length = 7).RSI;

def RSM_Stoch_Val = 100 * (close - lowest(low, 14)) / (highest(high, 14) - lowest(low, 14));
def RSM_StochSlowK = SimpleMovingAvg(SimpleMovingAvg(RSM_Stoch_Val,3),3);

def RSM_rsiGreen = RSM_RSI >= 50;
def RSM_rsiRed = RSM_RSI < 50;
def RSM_stochGreen = RSM_StochSlowK >= 50;
def RSM_stochRed = RSM_StochSlowK < 50;
def RSM_macdGreen = RSM_MACD_Diff >= 0;
def RSM_macdRed = RSM_MACD_Diff < 0;
def RSM_Buy = RSM_rsiGreen and RSM_stochGreen and RSM_macdGreen;
def RSM_Sell = RSM_rsiRed and RSM_stochRed and RSM_macdRed;

### Divergance
input HMA_Length = 55;
input HMA_Lookback = 2;

def HMA = HullMovingAvg(price = HL2, length = HMA_Length);
def HMA_delta = HMA[1] - HMA[HMA_Lookback + 1];
def HMA_delta_per_bar = HMA_delta / HMA_Lookback;
def HMA_next_bar = HMA[1] + HMA_delta_per_bar;
def HMA_concavity = if HMA > HMA_next_bar then 1 else -1;
def HMA_MA_Max = if HMA[-1] < HMA and HMA > HMA[1] then HMA else Double.NaN;
def HMA_MA_Min = if HMA[-1] > HMA and HMA < HMA[1] then HMA else Double.NaN;
def HMA_divergence = HMA - HMA_next_bar;

def HMA_SIGNAL =  if HMA_divergence[1] < HMA_divergence then 0 else if  HMA_divergence[1] < HMA_divergence then 1 else 1;

### Balance of Power

input BOP_EMA_Length = 20;
input BOP_TEMA_Length = 20;

def BOP_THL = If(high != low, high - low, 0.01);
def BOP_BullOpen = (high - open) / BOP_THL;
def BOP_BearOpen = (open - low) / BOP_THL;
def BOP_BullClose = (close - low) / BOP_THL;
def BOP_BearClose = (high - close) / BOP_THL;
def BOP_BullOC = If(close > open, (close - open) / BOP_THL, 0);
def BOP_BearOC = If(open > close, (open - close) / BOP_THL, 0);
def BOP_BullReward = (BOP_BullOpen + BOP_BullClose + BOP_BullOC) / 1;
def BOP_BearReward = (BOP_BearOpen + BOP_BearClose + BOP_BearOC) / 1;

def BOP_BOP = BOP_BullReward - BOP_BearReward;
def BOP_SmoothBOP = ExpAverage(BOP_BOP, BOP_EMA_Length);
def BOP_xPrice = BOP_SmoothBOP;
def BOP_xEMA1 = ExpAverage(BOP_SmoothBOP, BOP_TEMA_Length);
def BOP_xEMA2 = ExpAverage(BOP_xEMA1, BOP_TEMA_Length);
def BOP_xEMA3 = ExpAverage(BOP_xEMA2, BOP_TEMA_Length);
def BOP_nRes = 3 * BOP_xEMA1 - 3 * BOP_xEMA2 + BOP_xEMA3;

def BOP_SmootherBOP = BOP_nRes;
def BOP_s1 = BOP_SmoothBOP;
def BOP_s2 = BOP_SmootherBOP;
def BOP_s3 = BOP_SmootherBOP[2];
def BOP_Direction = if BarNumber() == 1 then 0
                    else if BOP_s2 < BOP_s3 and BOP_s2[1] > BOP_s3[1] then -1
                    else if BOP_s2 > BOP_s3 and BOP_s2[1] < BOP_s3[1] then 1
                    else BOP_Direction[1];

### Fibonacci SuperTrend

input FST_Length = 11;
input FST_Retrace = 23.6;
input FST_UseHighLow = yes;

def FST_h = if FST_UseHighLow then high else close;
def FST_l = if FST_UseHighLow then low else close;
def FST_minL = Lowest(FST_l, FST_Length);
def FST_maxH = Highest(FST_h, FST_Length);

def FST_hh = if FST_h > FST_maxH[1] then FST_h else FST_hh[1];
def FST_ll = if FST_l < FST_minL[1] then FST_l else FST_ll[1];
def FST_trend = if FST_h > FST_maxH[1] then 1 else if FST_l < FST_minL[1] then -1 else FST_trend[1];
def FST_Direction = if BarNumber() == 0 then 0
                    else if FST_trend != 1 then -1
                    else if FST_trend == 1 then 1
                    else FST_Direction[1];


### Strategy


def BullBear_Buy = if FST_Direction ==1 then FST_Direction == 1 else no;
plot signal1 = MF_SIGNAL and MACDBB_OVERALL_SIGNAL and RSM_Buy and HMA_SIGNAL and BOP_Direction and BullBear_Buy and !BullBear_Buy[1];
Thanks much @AspaTrader, @Chuck @barbaros. You guys are awesome.
When I added this scanner and updated the condition as signal1 is true, its giving ComplexExpressions Exception. Any one faced this issue.
 
This forum is pretty lively. I like it.

I completely agree with you. We had volume based indicators added but then removed since they don't work with indices and when you add a volume reference in an indicator for an instrument without volume, it makes the whole indicator stop working.

I think for the future, we'll have a volume add-on options that you can add to the end of the study. @Chuck has been doing some of that already with some of the add-ons. ADX is one of them.
An indicator that has been extremely helpful for me when evaluating volume was the Volume Indicator Lite version found here

https://usethinkscript.com/threads/...-stats-for-thinkorswim.970/page-11#post-47890

It's an upper study but gives a clear vision of where volume is at from multiple time frames at once. It also shows the percentage of volume for the day vs historical numbers. Maybe there is something there we can use. Not that I really have a clue, 😂 just trying to help. Keep on rockin in a free world gang!
 
We are working on some solutions to most all the request, If I did not respond to you directly, it's not that I am avoiding you, but that I am busy trying to help others. Thank all of you for your questions and suggestions. We are working tirelessly to make this not just a lower indicator, but an entire trading system designed to help navigate these markets in a clear, precise manner.
Hi Chuck,
This indicator is extremely useful and well thought out. Massive thank you to everyone who has contributed to this project! I am curious if it would be possible to change out the Bollinger Bands with Keltner channels? I know that is a bit off beat from the current design (sorry for the curve ball). I have attempted to do it myself, but it doesn't look right. Any help/insight on how to do this is much appreciated.
 
Hi Chuck,
This indicator is extremely useful and well thought out. Massive thank you to everyone who has contributed to this project! I am curious if it would be possible to change out the Bollinger Bands with Keltner channels? I know that is a bit off beat from the current design (sorry for the curve ball). I have attempted to do it myself, but it doesn't look right. Any help/insight on how to do this is much appreciated.
@Christopher84 ,

The well thought out portion is all Barbaros! He is amazing at what he does and uses sound logic as he carefully and skillfully orchestrates this project. I can't thank him enough for his insight and contribution here. The original base of this system used Keltner Channels to overlay the BB, it identified when they were in a squeeze. We just updated the indicator with what we feel is a better representation of that condition, of course we could have modified the the KC settings and possibly acquired a similar result but after careful consideration and testing we decided to take that out.

The whole premise of this indicator revolves around BB, and hence the name: Balanced_BB_Breakout. Balanced due to its ability to spot areas of purposed consolidation or equilibrium, BB due to using the Bollinger Bands to show a breakout.

When the upper and lower Bollinger Bands are moving towards each other, or the distance between the upper and lower bands is narrow (on a relative basis), it is a suggestion that the market under review is consolidating.

A consolidation phase suggests that the market is non-directional for the time being and now rangebound in nature. The narrow or narrowing Bollinger Bands will essentially move closer to the price and at some stage appear to be in what I like to term a "Balanced BB Squeeze" It is at this stage that breakout traders might pay attention.

I personally do not use the Keltner Channels and am not an expert on them by any means. All that being said, I am not sure that would be a good direction to take this indicator.

I am not the coder, but I am sure the code is getting pretty complex, meaning it may be reaching a level where adding more to it may make it not work in scans, watchlists and mobile...etc. Barbaros is the resident genius on all that. But for now it is my opinion just to not include it at this time.
 
Thanks much @AspaTrader, @Chuck @barbaros. You guys are awesome.
When I added this scanner and updated the condition as signal1 is true, its giving ComplexExpressions Exception. Any one faced this issue.
I am having issues with the final scan also (post 451) and have even plugged into thinkscript editor instead of condition wizard, and still not getting any results...I did happen to get results with scan from (post 444)...any suggestions? thx
 
Thanks much @AspaTrader, @Chuck @barbaros. You guys are awesome.
When I added this scanner and updated the condition as signal1 is true, its giving ComplexExpressions Exception. Any one faced this issue.
Still cant get the scanner to work, I have done the same thing, added the code and said when Signal1 is true but it throws an exception error has anyone else had success with the scanner, if yes, how did you set it up.
 
We'll have a newer scanner soon, or at least we are trying to have all functionality in it. Currently, it is difficult to keep the complexity of this study and have it as a full function scanner.
 
Last edited:
@barbaros @Chuck Just trying to make this amazing indicator even better what about adding some momentum what if we somehow incorporate spikes in Volume or spikes in Volume * Price basically we want the 3 strategies to line up with a buy signal but also add that if the current bar volume is >= the last 10 bar volumes. This will catch all of your momentum stocks and allows you to weed out the false signals especially on the lower time frames. a Perfect example of this today was STPK stock at 10:35 AM 5 min chart.
 
@Christopher84 ,

The well thought out portion is all Barbaros! He is amazing at what he does and uses sound logic as he carefully and skillfully orchestrates this project. I can't thank him enough for his insight and contribution here. The original base of this system used Keltner Channels to overlay the BB, it identified when they were in a squeeze. We just updated the indicator with what we feel is a better representation of that condition, of course we could have modified the the KC settings and possibly acquired a similar result but after careful consideration and testing we decided to take that out.

The whole premise of this indicator revolves around BB, and hence the name: Balanced_BB_Breakout. Balanced due to its ability to spot areas of purposed consolidation or equilibrium, BB due to using the Bollinger Bands to show a breakout.

When the upper and lower Bollinger Bands are moving towards each other, or the distance between the upper and lower bands is narrow (on a relative basis), it is a suggestion that the market under review is consolidating.

A consolidation phase suggests that the market is non-directional for the time being and now rangebound in nature. The narrow or narrowing Bollinger Bands will essentially move closer to the price and at some stage appear to be in what I like to term a "Balanced BB Squeeze" It is at this stage that breakout traders might pay attention.

I personally do not use the Keltner Channels and am not an expert on them by any means. All that being said, I am not sure that would be a good direction to take this indicator.

I am not the coder, but I am sure the code is getting pretty complex, meaning it may be reaching a level where adding more to it may make it not work in scans, watchlists and mobile...etc. Barbaros is the resident genius on all that. But for now it is my opinion just to not include it at this time.
Thank you for the prompt response. I definitely understand what you are saying. The indicator itself is built primarily around the BB. I have used BB for quite awhile and they are fantastic for all of the reasons you expressed. I currently use Keltner channels and STARC bands instead. The main difference is the use of ATR instead of standard deviation like the BB. Anyhow, its just a matter of preference. This indicator is exceptional. What an excellent collaboration! Maybe I will be able to figure out how to incorporate Keltner Channels of STARC Bands just for the visual without actually changing any of the signals currently built in. Thanks again!
 
We'll have a newer scanner soon, or at least we are trying to have all functionality in it. Currently, it is difficult to keep the complexity of this study and have it as a full function scanner.
No worries and seriously no rush... everyone appreciates all of the hard work you, chuck and aspa and cos has put into this project! thanks!! I just ask because I feel stupid trying and finally I'm like lemme just ask...
 
Here is a simple change you can make in the indicator script to make the Buy/Sell arrow only appear when all three signals (Balance of Power, Fibonacci Supertrend, and RSI IFT) are in a buy/sell state.

Find these lines:

Ruby:
def Strategy_Buy = BullBear_Buy and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BullBear_Sell and MACDBB_Sell and RSM_Sell;
def Strategy_BuySignal = Strategy_Buy and !Strategy_Buy[1];
def Strategy_SellSignal = Strategy_Sell and !Strategy_Sell[1];

and replace them with these:

Ruby:
def Strategy_Buy = BOP_Direction == 1 and FST_Direction == 1 and RSI_IFT_Direction == 1 and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BOP_Direction == -1 and FST_Direction == -1 and RSI_IFT_Direction == -1 and MACDBB_Sell and RSM_Sell;
def Strategy_BuySignal = Strategy_Buy and !Strategy_Buy[1];
def Strategy_SellSignal = Strategy_Sell and !Strategy_Sell[1];
Thanks!
 
Status
Not open for further replies.

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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