B4 Balanced BB Breakout For ThinkOrSwim

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

Good job and quick note. You could have stayed in your first trade longer. MACD BB didn't cross the top BB band. Your stop loss can be the last swing low and then look for previous resistance level for profit. Many ways to skin the cat, but your trade was cautious and probably will have less drawdowns.
Thanks for sharing... sharing is caring... I'm learning
 
@Chuck @barbaros maybe have a sub forum with a list of stocks that we find most succesfull and then we can ALL follow each other with trades sort of like a wallstbets type thing but with good quality, not too volatile stocks...



So I personally have just used Walmart WMT, LYFT and AMD. They're all not too volatile...LYFT is sweet and I mean sweet.
Look at this setup today...huge and all because of this great community of people!! :)

Here is the link to my setup if anyone wants:

http://tos.mx/EFkWHwP

My setup includes the following:



Here is an example of LYFT today and how I traded it:

1) You get the magical white arrow with the BBDot crossing above top of Bollinger Band.
2) Three X Stoch white arrow pointing up.
3) You get an up arrow with the SuperTrend (Cyan) Yahoo by RConner7.
4) The 5, 8, 13 (SMA fibonacci numbers) the 5 SMA (GOLD) crosses the 8 SMA (Strawberry) and then the 13 SMA (Blue)
5) ALSO look at @rad14733 Trend Reversal Indicator MOST EVERY TIME IT GIVES YOU EARLY CONFIRMATION!!

I got in around $59.50 and exited when the dark green MACDBB dot hit the top of Bolinger Band at about $60.99...


Nice example and explanation! Thank you! Much better than mine. You have all those fancy arrows and such!
 
Now if I was smart I would of looked at the 15 minute chart with the same setup!!

I could of rode it up to $61.95 :)

But I am not that smart...one day I will be!



In between the BLUE is where I entered and exited Prematurely...Instead I could of rode it up to the strawberry verticle line..


Also using the SUPER_MTF would of helped also...


@Joseph Patrick 18 What is that indicator your using to plot lines to the right from the swing lows and highs? I have one but it seems to go to far back and put up to many lines. I'll post a picture of the one I'm using but was curious about yours?

Do you have or know of any indicator that will plot a dot or put a dash below each price bar for stop reference?

My Stock Template
 
After doing some basic backtesting, I've found that a buy signal powered by just BOP, FST, and RSI_IFT (instead of RSM and MACDBB as well) has higher profit and similar drawdown. Anyone find anything similar or different?
 
After doing some basic backtesting, I've found that a buy signal powered by just BOP, FST, and RSI_IFT (instead of RSM and MACDBB as well) has higher profit and similar drawdown. Anyone find anything similar or different
Let me understand your saying when all 3 signals BOP/FST/RSI_IFT all have buy arrows it might have been better or more profitable?
 
After doing some basic backtesting, I've found that a buy signal powered by just BOP, FST, and RSI_IFT (instead of RSM and MACDBB as well) has higher profit and similar drawdown. Anyone find anything similar or different?

I can't speak to back testing because I'm not sure I can do it accurately. For real-time trading with real money, the MACD BB takes precedence over all else for me. That may be because I tend to trade off short timeframes (5 min or less) in the direction of higher timeframe trend. On short timeframes, even if BOP, FST, and RSI_IFT fire simultaneously, it can be a false signal. I can't speak to signal accuracy on higher timeframes because I haven't used BOP, FST, RSI_IFT very much for that.

For day trading the instruments I follow (mostly futures), I find that the strategy @Hypoluxa posted on the MACD BB thread hard to beat.** I like to use RSM-colored candles as additional trend info. I don't use BOP on short timeframes because it throws off too many signals. For short timeframes, I find simultaneous printing of RSI_IFT and FST helpful confirmations, but only when they align with higher timeframe trend and higher timeframe support/resistance zones.

I wouldn't enter a trade based on BOP, FST, and RSI_IFT signals alone. I lost money doing that but made money using signals in conjunction with other information. Maybe it's the instruments I trade or lack of skills as a trader. Anyway, none of this is meant as a criticism of the Balanced BB Breakout (the B4, as I call it) indicator. It's just that the B4 seems to work better for me as potential confirmation under certain circumstances rather than an all-inclusive trading system. Also, I find that when the RSI_IFT and FST signals fire simultaneously, when they are correct, they can signal a big move. I find that helpful to know when I'm deciding whether to take all my profits off the table or keep a little runner going.

**NOT a criticism of the B4 indicator. Just a statement to say that I think the MACD BB is a terrific indicator and still the most helpful information for my trading decisions.

Best wishes and happy trading.
 
Last edited:
**NOT a criticism of the B4 indicator. Just a statement to say that I think the MACD BB is a terrific indicator and still the most helpful information for my trading decisions.

Best wishes and happy trading.
Well I would think it's nice to have all view points!!!! I've done well with this package but I usually only take trades that have all 3 saying go long!
 
Good job and quick note. You could have stayed in your first trade longer. MACD BB didn't cross the top BB band. Your stop loss can be the last swing low and then look for previous resistance level for profit. Many ways to skin the cat, but your trade was cautious and probably will have less drawdowns.
I felt what he done is correct. What do you mean by MACD BB didn't cross the top BB band. Do you mind to elaborate? It would be great if you guys can create a video of how you use it. Thank you for all your helP!
 
I usually only take trades that have all 3 saying go long!

Just curious, what timeframe are you taking signals from, @svencool? One thing I'm looking at is whether signals from a higher timeframe give me an edge for earlier entry on my 2 and 3 min charts. I set up scans to alert me when signals pop on various timeframes between one hour and 5 min. Today I had a 30 min signal pop well before I saw anything on the 2 minute MACD BB or lower B4 strategy signals. The 2 minute eventually alerted as well, but it did so after most of the move already happened. That 30 min signal (FST and RSI_IFT) was spot-on.

It may be that the range of instruments I trade is too narrow to see all the benefits of the B4. Or maybe I need to take signals from a higher timeframe.
 
@Joseph Patrick 18 What is that indicator your using to plot lines to the right from the swing lows and highs? I have one but it seems to go to far back and put up to many lines. I'll post a picture of the one I'm using but was curious about yours?

Do you have or know of any indicator that will plot a dot or put a dash below each price bar for stop reference?

My Stock Template
If you're talking about these , it is Mobius's Fractal Pivots with Trendlines which I shared a link...

http://tos.mx/oK0PPVt

If its what your talking about in pic with arrows below...


 
Just curious, what timeframe are you taking signals from,
Being I have a Day job and can't do intraday trading. I usually look at 30min,60min, Daily, Weekly & Monthly sometimes. I just like to have the wind at my back when ever possible. With this new indicator I wait for all 3 to signal a buy or go long. Then I look at other indicators to confirm. I'm trying to weed that list down to only a couple as when I have to many. Sometimes I won't take a position when I should have. But I'm still very green so to speak and am learning at a fast rate.
 
@Joseph Patrick 18 What is that indicator your using to plot lines to the right from the swing lows and highs? I have one but it seems to go to far back and put up to many lines. I'll post a picture of the one I'm using but was curious about yours?

Do you have or know of any indicator that will plot a dot or put a dash below each price bar for stop reference?

My Stock Templat
I think I might have something gimme the day to look thru all my indicators:)
 
Guys, lets declare the latest bate to be the next version. It's minor changes but adds more flexibility. I also added hints. @Chuck, the first page.

Code:
# 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
# v2.5 - 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
# v2.6 - Barbaros - optimizations, added hints and separated out BullBear options for combinations

declare lower;

input ShowMarketForecastLabel = yes;        #hint ShowMarketForecastLabel: Show the intermediate Market Forecast label
input ShowMACDBBLabel = yes;                #hint ShowMACDBBLabel: Show the MACDBB based Trend label
input ShowMACDBBCloud = no;                 #hint ShowMACDBBCloud: Show the MACDBB cloud shaded between BB
input ShowRSMCloud = no;                    #hint ShowRSMCloud: Show the vertical cloud based on RSM
input ShowHMALabel = yes;                   #hint ShowHMALabel: Show HUll Moving Average based Divergence label
input ShowSTOCHSCALPERSqueezeLabel = yes;   #hint ShowSTOCHSCALPERSqueezeLabel: Show Stochastic Scalper based squeeze label
input ShowSTOCHSCALPERSqueezeCloud = yes;   #hint ShowSTOCHSCALPERSqueezeCloud: Show Stochastic Scalper based squeeze cloud between BB
input ShowBullBearVerticalLines = yes;      #hint ShowBullBearVerticalLines: Show vertical lines for bullish or bearish direction

### Market Forecast

def pIntermediate = MarketForecast().Intermediate;

AddLabel(ShowMarketForecastLabel,
    "Market Forecast " +
    if pIntermediate >= 80 then "Bullish" else
    if pIntermediate <= 20 then "Bearish" else
    if pIntermediate > pIntermediate[1] then "Rising" else
    if pIntermediate < pIntermediate[1] then "Falling" else "Neutral",
    if pIntermediate >= 80 then Color.GREEN else
    if pIntermediate <= 20 then Color.RED else
    if pIntermediate > pIntermediate[1] then Color.LIGHT_GREEN else
    if pIntermediate < pIntermediate[1] then Color.LIGHT_RED else Color.GRAY
);

### MACDBB

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

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

plot MACDBB_Upper = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;
MACDBB_Upper.SetDefaultColor(Color.RED);
MACDBB_Upper.HideTitle();
MACDBB_Upper.HideBubble();

plot MACDBB_Lower = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;
MACDBB_Lower.SetDefaultColor(Color.GREEN);
MACDBB_Lower.HideTitle();
MACDBB_Lower.HideBubble();

plot MACDBB_Midline = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                               Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).MidLine;
MACDBB_Midline.SetDefaultColor(Color.LIGHT_RED);
MACDBB_Midline.SetStyle(Curve.FIRM);
MACDBB_MidLine.HideTitle();
MACDBB_MidLine.HideBubble();

plot MACDBB_Line = MACDBB_Data;
MACDBB_Line.AssignValueColor(
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper then Color.GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper then Color.DARK_GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower then Color.RED else
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower then Color.DARK_RED
    else Color.GRAY
);
MACDBB_Line.SetLineWeight(1);

plot MACDBB_Dots = MACDBB_Data;
MACDBB_Dots.AssignValueColor(
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.DARK_GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.RED
    else if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.DARK_RED
    else Color.GRAY
);
MACDBB_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACDBB_Dots.SetLineWeight(1);
MACDBB_Dots.HideTitle();
MACDBB_Dots.HideBubble();

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;

AddLabel(ShowMACDBBLabel,
    "Trend " +
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then "Bullish"
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then "Bullish (decreasing)"
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then "Bearish"
    else if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then "Bearish (increasing)"
    else "Neutral",
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.DARK_GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.RED
    else if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.DARK_RED
    else Color.GRAY
);

AddCloud(if ShowMACDBBCloud then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.LIGHT_RED);

### RSI/STOCASTIC/MACD CONFLUENCE COMBO

plot RSM_MACD_Diff = reference MACD("fast length" = 12, "slow length" = 26, "macd length" = 9).Diff;
RSM_MACD_Diff.SetDefaultColor(GetColor(5));
RSM_MACD_Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RSM_MACD_Diff.SetLineWeight(4);
RSM_MACD_Diff.DefineColor("Positive and Up", Color.GREEN);
RSM_MACD_Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
RSM_MACD_Diff.DefineColor("Negative and Down", Color.RED);
RSM_MACD_Diff.DefineColor("Negative and Up", Color.DARK_RED);
RSM_MACD_Diff.AssignValueColor(
    if RSM_MACD_Diff >= 0 then
        if RSM_MACD_Diff > RSM_MACD_Diff[1] then RSM_MACD_Diff.Color("Positive and Up") else RSM_MACD_Diff.Color("Positive and Down")
    else
        if RSM_MACD_Diff < RSM_MACD_Diff[1] then RSM_MACD_Diff.Color("Negative and Down") else RSM_MACD_Diff.Color("Negative and Up")
);

plot RSM_MACD_ZeroLine = 0;
RSM_MACD_ZeroLine.SetDefaultColor(Color.RED);
RSM_MACD_ZeroLine.HideTitle();
RSM_MACD_ZeroLine.HideBubble();

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;

# Shade areas based on criteria; adjust as needed

AddCloud(
    if ShowRSMCloud and RSM_rsiGreen and RSM_stochGreen and RSM_macdGreen then Double.POSITIVE_INFINITY else Double.NaN,
    if ShowRSMCloud and RSM_rsiGreen and RSM_stochGreen and RSM_macdGreen then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN
);
AddCloud(
    if ShowRSMCloud and RSM_rsiRed and RSM_stochRed and RSM_macdRed then Double.POSITIVE_INFINITY else Double.NaN,
    if ShowRSMCloud and RSM_rsiRed and RSM_stochRed and RSM_macdRed then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_RED
);

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

AddLabel(ShowHMALabel,
        "Divergence " +
        if HMA_concavity < 0 then
            if HMA_divergence[1] > HMA_divergence then "Bearish (increasing)"
            else "Bearish"
        else
            if HMA_divergence[1] < HMA_divergence then "Bullish (decreasing)"
            else "Bullish",
        if HMA_concavity < 0 then
            if HMA_divergence[1] > HMA_divergence then Color.DARK_RED
            else Color.RED
        else
            if HMA_divergence[1] < HMA_divergence then Color.DARK_GREEN
            else Color.GREEN
);

### Stocastic Scalper

def STOCHSCALPER_oSS = (open[1] + close[1]) / 2;
def STOCHSCALPER_hSS = Max(high, close[1]);
def STOCHSCALPER_lSS = Min(low, close[1]);
def STOCHSCALPER_cSS = (STOCHSCALPER_oSS + STOCHSCALPER_hSS + STOCHSCALPER_lSS + close) / 4;

def STOCHSCALPER_mean = Average(STOCHSCALPER_cSS, 20);
def STOCHSCALPER_sd = StDev(STOCHSCALPER_cSS, 20);
def STOCHSCALPER_atr = Average(TrueRange(STOCHSCALPER_cSS, STOCHSCALPER_hSS, STOCHSCALPER_lSS), 20);
def STOCHSCALPER_squeeze = if (STOCHSCALPER_mean + (2 * STOCHSCALPER_sd)) < (STOCHSCALPER_mean + (1.5 * STOCHSCALPER_atr)) then yes else no;
def STOCHSCALPER_squeeze_signal = !STOCHSCALPER_squeeze[1] and STOCHSCALPER_squeeze;

AddCloud(if ShowSTOCHSCALPERSqueezeCloud and STOCHSCALPER_squeeze then MACDBB_Upper else Double.NaN,
         if ShowSTOCHSCALPERSqueezeCloud and STOCHSCALPER_squeeze then MACDBB_Lower else Double.NaN, Color.YELLOW);
AddLabel(ShowSTOCHSCALPERSqueezeLabel, "Scalper Squeeze", if STOCHSCALPER_squeeze then Color.WHITE else Color.GRAY);

### 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];

### RSI IFT

def RSI_IFT_R = reference RSI(5, close) - 50;
def RSI_IFT_AvgRSI = MovingAverage(AverageType.Exponential,RSI_IFT_R,9);
def RSI_IFT_InverseRSI = (Power(Double.E, 2 * RSI_IFT_AvgRSI) - 1) / (Power(Double.E, 2 * RSI_IFT_AvgRSI) + 1);
def RSI_IFT_Direction = if BarNumber() == 0 then 0
                        else if (RSI_IFT_InverseRSI[1] > 0) and (RSI_IFT_InverseRSI < 0) then -1
                        else if (RSI_IFT_InverseRSI > 0) and (RSI_IFT_InverseRSI[1] < 0) then 1
                        else RSI_IFT_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];

### Bar Color

input BarColor = { "None", default "RSM", "FibonacciSuperTrend" };    #hint BarColor: Paint bars with RSM or Fibonacci SuperTrend direction

AssignPriceColor(
    if BarColor == BarColor.FibonacciSuperTrend then
        if FST_trend == 1 then Color.GREEN else Color.RED
    else if BarColor == BarColor.RSM then
        if RSM_Buy then Color.GREEN
        else if RSM_Sell then Color.RED
        else Color.DARK_GRAY
    else Color.CURRENT
);

### Strategy

input BullBear_Include_BOP = no;        #hint BullBear_Include_BOP: Include Balance of Power in the vertical line strategy
input BullBear_Include_FST = yes;       #hint BullBear_Include_FST: Include Fibonacci SuperTrend in the vertical line strategy
input BullBear_Include_RSI_IFT = yes;   #hint BullBear_Include_RSI_IFT: Include RSI IFT in the vertical line strategy

def BullBear_Buy = (!BullBear_Include_BOP or BOP_Direction == 1) and
                   (!BullBear_Include_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!BullBear_Include_BOP or BOP_Direction == -1) and
                    (!BullBear_Include_FST or FST_Direction == -1) and
                    (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == -1);

AddVerticalLine(ShowBullBearVerticalLines and BullBear_Buy and !BullBear_Buy[1],
                AsDollars(close),
                Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(ShowBullBearVerticalLines and BullBear_Sell and !BullBear_Sell[1], 
                AsDollars(close),
                Color.RED, Curve.SHORT_DASH);

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

plot BuyArrow = if Strategy_BuySignal then 0 else Double.NaN;
BuyArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuyArrow.SetDefaultColor(Color.WHITE);
BuyArrow.HideTitle();
BuyArrow.HideBubble();

plot SellArrow = if Strategy_SellSignal then 0 else Double.NaN;
SellArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellArrow.SetDefaultColor(Color.WHITE);
SellArrow.HideTitle();
SellArrow.HideBubble();

### Alerts

Alert(Strategy_BuySignal, "Long Entry", Alert.BAR, Sound.DING);
Alert(Strategy_SellSignal, "Short Entry", Alert.BAR, Sound.DING);
Alert(MACDBB_Line crosses above MACDBB_CrossFromAboveVal, "MACDBB Crossed Up", Alert.BAR, Sound.DING);
Alert(MACDBB_Line crosses below MACDBB_CrossFromBelowVal, "MACDBB Crossed Down", Alert.BAR, Sound.DING);
Alert(STOCHSCALPER_squeeze_signal, "Scalper Squeeze", Alert.BAR, Sound.DING);

and the scanner update.

Code:
# Balanced BB Breakout Scanner
#
# 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 - Scanner Update, removed Market Forecast, HULL Concavity and Squeeze due to ToS limitation
# v2.1 - Barbaros - Separated out BullBear options for combinations

### 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_Buy = MACDBB_Data > MACDBB_Upper;
def MACDBB_Sell = MACDBB_Data <= MACDBB_Lower;

### RSI/STOCASTIC/MACD CONFLUENCE COMBO

def RSM_MACD_Diff = reference MACD(fastLength = 12, slowLength = 26, MACDLength = 9).Diff;
def RSM_MACD_ZeroLine = 0;
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;

### 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];

### RSI IFT

def RSI_IFT_R = reference RSI(5, close) - 50;
def RSI_IFT_AvgRSI = MovingAverage(AverageType.Exponential,RSI_IFT_R,9);
def RSI_IFT_InverseRSI = (Power(Double.E, 2 * RSI_IFT_AvgRSI) - 1) / (Power(Double.E, 2 * RSI_IFT_AvgRSI) + 1);
def RSI_IFT_Direction = if BarNumber() == 0 then 0
                        else if (RSI_IFT_InverseRSI[1] > 0) and (RSI_IFT_InverseRSI < 0) then -1
                        else if (RSI_IFT_InverseRSI > 0) and (RSI_IFT_InverseRSI[1] < 0) then 1
                        else RSI_IFT_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

input BullBear_Include_BOP = no;        #hint BullBear_Include_BOP: Include Balance of Power in the vertical line strategy
input BullBear_Include_FST = yes;       #hint BullBear_Include_FST: Include Fibonacci SuperTrend in the vertical line strategy
input BullBear_Include_RSI_IFT = yes;   #hint BullBear_Include_RSI_IFT: Include RSI IFT in the vertical line strategy

def BullBear_Buy = (!BullBear_Include_BOP or BOP_Direction == 1) and
                   (!BullBear_Include_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!BullBear_Include_BOP or BOP_Direction == -1) and
                    (!BullBear_Include_FST or FST_Direction == -1) and
                    (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == -1);

def Strategy_Buy = BullBear_Buy and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BullBear_Sell and MACDBB_Sell and RSM_Sell;

plot StrategyArrow = if Strategy_Buy and !Strategy_Buy[1] then 1
                    else if Strategy_Sell and !Strategy_Sell[1] then -1
                    else 0;
 
I can't get the scanner to work. Do I need to comment out any lines. It worked earlier. it says Error: Script Execution Timeout
Guys, lets declare the latest bate to be the next version. It's minor changes but adds more flexibility. I also added hints. @Chuck, the first page.

Code:
# 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
# v2.5 - 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
# v2.6 - Barbaros - optimizations, added hints and separated out BullBear options for combinations

declare lower;

input ShowMarketForecastLabel = yes;        #hint ShowMarketForecastLabel: Show the intermediate Market Forecast label
input ShowMACDBBLabel = yes;                #hint ShowMACDBBLabel: Show the MACDBB based Trend label
input ShowMACDBBCloud = no;                 #hint ShowMACDBBCloud: Show the MACDBB cloud shaded between BB
input ShowRSMCloud = no;                    #hint ShowRSMCloud: Show the vertical cloud based on RSM
input ShowHMALabel = yes;                   #hint ShowHMALabel: Show HUll Moving Average based Divergence label
input ShowSTOCHSCALPERSqueezeLabel = yes;   #hint ShowSTOCHSCALPERSqueezeLabel: Show Stochastic Scalper based squeeze label
input ShowSTOCHSCALPERSqueezeCloud = yes;   #hint ShowSTOCHSCALPERSqueezeCloud: Show Stochastic Scalper based squeeze cloud between BB
input ShowBullBearVerticalLines = yes;      #hint ShowBullBearVerticalLines: Show vertical lines for bullish or bearish direction

### Market Forecast

def pIntermediate = MarketForecast().Intermediate;

AddLabel(ShowMarketForecastLabel,
    "Market Forecast " +
    if pIntermediate >= 80 then "Bullish" else
    if pIntermediate <= 20 then "Bearish" else
    if pIntermediate > pIntermediate[1] then "Rising" else
    if pIntermediate < pIntermediate[1] then "Falling" else "Neutral",
    if pIntermediate >= 80 then Color.GREEN else
    if pIntermediate <= 20 then Color.RED else
    if pIntermediate > pIntermediate[1] then Color.LIGHT_GREEN else
    if pIntermediate < pIntermediate[1] then Color.LIGHT_RED else Color.GRAY
);

### MACDBB

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

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

plot MACDBB_Upper = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;
MACDBB_Upper.SetDefaultColor(Color.RED);
MACDBB_Upper.HideTitle();
MACDBB_Upper.HideBubble();

plot MACDBB_Lower = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;
MACDBB_Lower.SetDefaultColor(Color.GREEN);
MACDBB_Lower.HideTitle();
MACDBB_Lower.HideBubble();

plot MACDBB_Midline = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                               Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).MidLine;
MACDBB_Midline.SetDefaultColor(Color.LIGHT_RED);
MACDBB_Midline.SetStyle(Curve.FIRM);
MACDBB_MidLine.HideTitle();
MACDBB_MidLine.HideBubble();

plot MACDBB_Line = MACDBB_Data;
MACDBB_Line.AssignValueColor(
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper then Color.GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper then Color.DARK_GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower then Color.RED else
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower then Color.DARK_RED
    else Color.GRAY
);
MACDBB_Line.SetLineWeight(1);

plot MACDBB_Dots = MACDBB_Data;
MACDBB_Dots.AssignValueColor(
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.DARK_GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.RED
    else if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.DARK_RED
    else Color.GRAY
);
MACDBB_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACDBB_Dots.SetLineWeight(1);
MACDBB_Dots.HideTitle();
MACDBB_Dots.HideBubble();

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;

AddLabel(ShowMACDBBLabel,
    "Trend " +
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then "Bullish"
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then "Bullish (decreasing)"
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then "Bearish"
    else if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then "Bearish (increasing)"
    else "Neutral",
    if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper then Color.DARK_GREEN
    else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.RED
    else if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower then Color.DARK_RED
    else Color.GRAY
);

AddCloud(if ShowMACDBBCloud then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.LIGHT_RED);

### RSI/STOCASTIC/MACD CONFLUENCE COMBO

plot RSM_MACD_Diff = reference MACD("fast length" = 12, "slow length" = 26, "macd length" = 9).Diff;
RSM_MACD_Diff.SetDefaultColor(GetColor(5));
RSM_MACD_Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RSM_MACD_Diff.SetLineWeight(4);
RSM_MACD_Diff.DefineColor("Positive and Up", Color.GREEN);
RSM_MACD_Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
RSM_MACD_Diff.DefineColor("Negative and Down", Color.RED);
RSM_MACD_Diff.DefineColor("Negative and Up", Color.DARK_RED);
RSM_MACD_Diff.AssignValueColor(
    if RSM_MACD_Diff >= 0 then
        if RSM_MACD_Diff > RSM_MACD_Diff[1] then RSM_MACD_Diff.Color("Positive and Up") else RSM_MACD_Diff.Color("Positive and Down")
    else
        if RSM_MACD_Diff < RSM_MACD_Diff[1] then RSM_MACD_Diff.Color("Negative and Down") else RSM_MACD_Diff.Color("Negative and Up")
);

plot RSM_MACD_ZeroLine = 0;
RSM_MACD_ZeroLine.SetDefaultColor(Color.RED);
RSM_MACD_ZeroLine.HideTitle();
RSM_MACD_ZeroLine.HideBubble();

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;

# Shade areas based on criteria; adjust as needed

AddCloud(
    if ShowRSMCloud and RSM_rsiGreen and RSM_stochGreen and RSM_macdGreen then Double.POSITIVE_INFINITY else Double.NaN,
    if ShowRSMCloud and RSM_rsiGreen and RSM_stochGreen and RSM_macdGreen then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN
);
AddCloud(
    if ShowRSMCloud and RSM_rsiRed and RSM_stochRed and RSM_macdRed then Double.POSITIVE_INFINITY else Double.NaN,
    if ShowRSMCloud and RSM_rsiRed and RSM_stochRed and RSM_macdRed then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_RED
);

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

AddLabel(ShowHMALabel,
        "Divergence " +
        if HMA_concavity < 0 then
            if HMA_divergence[1] > HMA_divergence then "Bearish (increasing)"
            else "Bearish"
        else
            if HMA_divergence[1] < HMA_divergence then "Bullish (decreasing)"
            else "Bullish",
        if HMA_concavity < 0 then
            if HMA_divergence[1] > HMA_divergence then Color.DARK_RED
            else Color.RED
        else
            if HMA_divergence[1] < HMA_divergence then Color.DARK_GREEN
            else Color.GREEN
);

### Stocastic Scalper

def STOCHSCALPER_oSS = (open[1] + close[1]) / 2;
def STOCHSCALPER_hSS = Max(high, close[1]);
def STOCHSCALPER_lSS = Min(low, close[1]);
def STOCHSCALPER_cSS = (STOCHSCALPER_oSS + STOCHSCALPER_hSS + STOCHSCALPER_lSS + close) / 4;

def STOCHSCALPER_mean = Average(STOCHSCALPER_cSS, 20);
def STOCHSCALPER_sd = StDev(STOCHSCALPER_cSS, 20);
def STOCHSCALPER_atr = Average(TrueRange(STOCHSCALPER_cSS, STOCHSCALPER_hSS, STOCHSCALPER_lSS), 20);
def STOCHSCALPER_squeeze = if (STOCHSCALPER_mean + (2 * STOCHSCALPER_sd)) < (STOCHSCALPER_mean + (1.5 * STOCHSCALPER_atr)) then yes else no;
def STOCHSCALPER_squeeze_signal = !STOCHSCALPER_squeeze[1] and STOCHSCALPER_squeeze;

AddCloud(if ShowSTOCHSCALPERSqueezeCloud and STOCHSCALPER_squeeze then MACDBB_Upper else Double.NaN,
         if ShowSTOCHSCALPERSqueezeCloud and STOCHSCALPER_squeeze then MACDBB_Lower else Double.NaN, Color.YELLOW);
AddLabel(ShowSTOCHSCALPERSqueezeLabel, "Scalper Squeeze", if STOCHSCALPER_squeeze then Color.WHITE else Color.GRAY);

### 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];

### RSI IFT

def RSI_IFT_R = reference RSI(5, close) - 50;
def RSI_IFT_AvgRSI = MovingAverage(AverageType.Exponential,RSI_IFT_R,9);
def RSI_IFT_InverseRSI = (Power(Double.E, 2 * RSI_IFT_AvgRSI) - 1) / (Power(Double.E, 2 * RSI_IFT_AvgRSI) + 1);
def RSI_IFT_Direction = if BarNumber() == 0 then 0
                        else if (RSI_IFT_InverseRSI[1] > 0) and (RSI_IFT_InverseRSI < 0) then -1
                        else if (RSI_IFT_InverseRSI > 0) and (RSI_IFT_InverseRSI[1] < 0) then 1
                        else RSI_IFT_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];

### Bar Color

input BarColor = { "None", default "RSM", "FibonacciSuperTrend" };    #hint BarColor: Paint bars with RSM or Fibonacci SuperTrend direction

AssignPriceColor(
    if BarColor == BarColor.FibonacciSuperTrend then
        if FST_trend == 1 then Color.GREEN else Color.RED
    else if BarColor == BarColor.RSM then
        if RSM_Buy then Color.GREEN
        else if RSM_Sell then Color.RED
        else Color.DARK_GRAY
    else Color.CURRENT
);

### Strategy

input BullBear_Include_BOP = no;        #hint BullBear_Include_BOP: Include Balance of Power in the vertical line strategy
input BullBear_Include_FST = yes;       #hint BullBear_Include_FST: Include Fibonacci SuperTrend in the vertical line strategy
input BullBear_Include_RSI_IFT = yes;   #hint BullBear_Include_RSI_IFT: Include RSI IFT in the vertical line strategy

def BullBear_Buy = (!BullBear_Include_BOP or BOP_Direction == 1) and
                   (!BullBear_Include_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!BullBear_Include_BOP or BOP_Direction == -1) and
                    (!BullBear_Include_FST or FST_Direction == -1) and
                    (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == -1);

AddVerticalLine(ShowBullBearVerticalLines and BullBear_Buy and !BullBear_Buy[1],
                AsDollars(close),
                Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(ShowBullBearVerticalLines and BullBear_Sell and !BullBear_Sell[1],
                AsDollars(close),
                Color.RED, Curve.SHORT_DASH);

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

plot BuyArrow = if Strategy_BuySignal then 0 else Double.NaN;
BuyArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuyArrow.SetDefaultColor(Color.WHITE);
BuyArrow.HideTitle();
BuyArrow.HideBubble();

plot SellArrow = if Strategy_SellSignal then 0 else Double.NaN;
SellArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellArrow.SetDefaultColor(Color.WHITE);
SellArrow.HideTitle();
SellArrow.HideBubble();

### Alerts

Alert(Strategy_BuySignal, "Long Entry", Alert.BAR, Sound.DING);
Alert(Strategy_SellSignal, "Short Entry", Alert.BAR, Sound.DING);
Alert(MACDBB_Line crosses above MACDBB_CrossFromAboveVal, "MACDBB Crossed Up", Alert.BAR, Sound.DING);
Alert(MACDBB_Line crosses below MACDBB_CrossFromBelowVal, "MACDBB Crossed Down", Alert.BAR, Sound.DING);
Alert(STOCHSCALPER_squeeze_signal, "Scalper Squeeze", Alert.BAR, Sound.DING);

and the scanner update.

Code:
# Balanced BB Breakout Scanner
#
# 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 - Scanner Update, removed Market Forecast, HULL Concavity and Squeeze due to ToS limitation
# v2.1 - Barbaros - Separated out BullBear options for combinations

### 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_Buy = MACDBB_Data > MACDBB_Upper;
def MACDBB_Sell = MACDBB_Data <= MACDBB_Lower;

### RSI/STOCASTIC/MACD CONFLUENCE COMBO

def RSM_MACD_Diff = reference MACD(fastLength = 12, slowLength = 26, MACDLength = 9).Diff;
def RSM_MACD_ZeroLine = 0;
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;

### 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];

### RSI IFT

def RSI_IFT_R = reference RSI(5, close) - 50;
def RSI_IFT_AvgRSI = MovingAverage(AverageType.Exponential,RSI_IFT_R,9);
def RSI_IFT_InverseRSI = (Power(Double.E, 2 * RSI_IFT_AvgRSI) - 1) / (Power(Double.E, 2 * RSI_IFT_AvgRSI) + 1);
def RSI_IFT_Direction = if BarNumber() == 0 then 0
                        else if (RSI_IFT_InverseRSI[1] > 0) and (RSI_IFT_InverseRSI < 0) then -1
                        else if (RSI_IFT_InverseRSI > 0) and (RSI_IFT_InverseRSI[1] < 0) then 1
                        else RSI_IFT_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

input BullBear_Include_BOP = no;        #hint BullBear_Include_BOP: Include Balance of Power in the vertical line strategy
input BullBear_Include_FST = yes;       #hint BullBear_Include_FST: Include Fibonacci SuperTrend in the vertical line strategy
input BullBear_Include_RSI_IFT = yes;   #hint BullBear_Include_RSI_IFT: Include RSI IFT in the vertical line strategy

def BullBear_Buy = (!BullBear_Include_BOP or BOP_Direction == 1) and
                   (!BullBear_Include_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!BullBear_Include_BOP or BOP_Direction == -1) and
                    (!BullBear_Include_FST or FST_Direction == -1) and
                    (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == -1);

def Strategy_Buy = BullBear_Buy and MACDBB_Buy and RSM_Buy;
def Strategy_Sell = BullBear_Sell and MACDBB_Sell and RSM_Sell;

plot StrategyArrow = if Strategy_Buy and !Strategy_Buy[1] then 1
                    else if Strategy_Sell and !Strategy_Sell[1] then -1
                    else 0;

can't get the scanner to give me any results on the daily time frame. Do I need to comment out some lines
[/QUOTE]
https://imgur.com/DrQIAdI
[ATTACH=full]10350[/ATTACH]
 
Last edited:
I can't get the scanner to work.

@Sammy800, have you tried scanning for not equal to zero? That should return +1 or -1 signals. Attached is an image for the way I set up a scan.


When I ran one instance of the scan code, it returned signals for either FST or RSI_IFT. I wanted a scan to show when both signals fired within 2 candles of each other. So I added a condition for each signal.

Under "Add condition group" at the top right, I selected "All of the following" so that the scan would return results only when both signals fire. As far as I can tell, the results of the scan are spot-on accurate.

I really appreciate the scanner for this indicator because it helps me quickly sift through my watch list. It's especially useful to scan across multiple timeframes to find which instruments are firing signals on both lower and higher timeframes.
 
Last edited:
I can't get the scanner to work. Do I need to comment out any lines. It worked earlier. it says Error: Script Execution Timeout

@Sammy800 I've noticed that scanning a bunch of stocks brings up that "Error: Script Execution Timeout" as well. I believe the scan script cannot be run on "All Stocks." I've had more luck limiting it to the stocks on S&P500 or smaller indexes. You can also scan in Weeklys like @Chuck has suggested before.

Also, the newest scan that @barbaros posted in Post #688 can be adjusted to scan for the 3 different strategies. Default on is RSI_IFT and FST.

You just need to change this section of the scanner code (the no and yes parts) to decide which strategies you want to scan for:
Code:
### Strategy

input BullBear_Include_BOP = no;        #hint BullBear_Include_BOP: Include Balance of Power in the vertical line strategy
input BullBear_Include_FST = yes;       #hint BullBear_Include_FST: Include Fibonacci SuperTrend in the vertical line strategy
input BullBear_Include_RSI_IFT = yes;   #hint BullBear_Include_RSI_IFT: Include RSI IFT in the vertical line strategy

I'm new here and have been lurking, but just want to thank everyone for all they've done to create and improve the indicator!
 
Status
Not open for further replies.

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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