B4 Balanced BB Breakout For ThinkOrSwim

Status
Not open for further replies.
@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!
Thanks your suggestion worked I was scanning in all stocks and thats why it wasnt working.🙏🙏🙏
 

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

@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.
Thanks for sharing the different combination. I would not have tried that out without your visual post. Thanks 🙏
 
Thanks, @barbaros @Chuck and others... What you guys have created and posted is a differentiator for improving probabilities on trades that work. I really like the MACDBB, RSM_MACD_Diff, and the Divergence label.

I trade 3 futures products - ZB (treasury bonds), crude oil, and gold on a 5-min candle chart.
I have a few questions:
1) How should one use the "Scalper Squeeze" label? What does it do?
2) What stop loss would you recommend? I wouldn't consider your response as trade advice.
 
Thanks, @barbaros @Chuck and others... What you guys have created and posted is a differentiator for improving probabilities on trades that work. I really like the MACDBB, RSM_MACD_Diff, and the Divergence label.

I trade 3 futures products - ZB (treasury bonds), crude oil, and gold on a 5-min candle chart.
I have a few questions:
1) How should one use the "Scalper Squeeze" label? What does it do?
2) What stop loss would you recommend? I wouldn't consider your response as trade advice.
Scalper Squeeze is where the price is squeezed to a range. You look for breakouts. It is also painted as a band on the chart.
Stop loss is dependent on your trading strategy. You can look at last pivots, ATR, etc.
 
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;
@barbaros A couple of questions. 1)On your scan, when I run it, I only get stocks with the green dot. Does it scan for red dots or bearish plays? If so, how do I enable it to scan for that? The only choice in the scan is for the Strategy Arrow.
2) You mentioned you separated the bull/bear options for combinations. What does that mean? Can I scan for bull and bear plays?
Thanks for your time.
 
@barbaros A couple of questions. 1)On your scan, when I run it, I only get stocks with the green dot. Does it scan for red dots or bearish plays? If so, how do I enable it to scan for that? The only choice in the scan is for the Strategy Arrow.
2) You mentioned you separated the bull/bear options for combinations. What does that mean? Can I scan for bull and bear plays?
Thanks for your time.
Hey @Tradervic, there are 3 states for strategy arrow, 0 = no signal, 1 = up arrow, -1 = down arrow. So, if you set up your scan to show values for strategy arrow not equal to 0, you should get both. If your list doesn't contain the direction you are not expecting, there might be no available stocks with that signal.
 
Thanks your suggestion worked I was scanning in all stocks and thats why it wasnt working.🙏🙏🙏

@Sammy800, the scan code works with "All Stocks" and "All Symbols." Here's the result for "All Stocks" with daily and 30 min signals (RSI_IFT and FST) between $5 and $50 with minimum 500K volume. I had these scan criteria for "All Symbols" in a sidebar today and it updated results just fine. Only thing is, the signals may not be firing in the same direction. Daily may be showing a long and the 30 min may be showing a short. My solution is to open the chart in a multi-cell grid where I can quickly see if everything is firing in the same direction.


You can also use the "Intersect with" function to further filter the list, for example, if you wanted to see how many of the stocks from the scan above have weekly options.


Best wishes and happy trading!
 
Has anyone got the script to scan for when all 3 strategies signal a Buy/Sell? cannot get the scan to wrk on a smaller timeframe lets say 5M n do a scan for when all 3 strategy spit out a BUY/SELL signal
 
Has anyone got the script to scan for when all 3 strategies signal a Buy/Sell? cannot get the scan to wrk on a smaller timeframe lets say 5M n do a scan for when all 3 strategy spit out a BUY/SELL signal

Yes, it works.


A quick check of about half the symbols show all 3 signals firing. On a 5m chart though, you have to be quick because BOP throws off so many signals. While I was checking, BOP was already printing signals that contradicted the RSI_IFT and and FST on some of these instruments.

Best wishes and happy trading.
 
Last edited:
  • Like
Reactions: Kaz
Yes, it works.


A quick check of about half the symbols show all 3 signals firing. On a 5m chart though, you have to be quick because BOP throws off so many signals. While I was checking, BOP was already printing signals that contradicted the RSI_IFT and and FST on some of these instruments.

Best wishes and happy trading.
Is this the scanner code or the actual indicator code? Could you please show a screen shot of your parameter that you have set inside those study scans?
 
@Sammy800, the scan code works with "All Stocks" and "All Symbols." Here's the result for "All Stocks" with daily and 30 min signals (RSI_IFT and FST) between $5 and $50 with minimum 500K volume. I had these scan criteria for "All Symbols" in a sidebar today and it updated results just fine. Only thing is, the signals may not be firing in the same direction. Daily may be showing a long and the 30 min may be showing a short. My solution is to open the chart in a multi-cell grid where I can quickly see if everything is firing in the same direction.


You can also use the "Intersect with" function to further filter the list, for example, if you wanted to see how many of the stocks from the scan above have weekly options.


Best wishes and happy trading!
Great scan setup that you posted. picks up great stocks to trade. thanks🙏
 
Small update for PnL calculations. I believe I resolved some issues but removed the ability to limit to intraday only. May be @cos251 can add the intraday limit. I will need to rewrite the PnL calculator to make it work for only intraday.

Python:
# 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

declare lower;

# Market Forecast
def pIntermediate = MarketForecast().Intermediate;

AddLabel(yes,
    "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 " ",
    if pIntermediate >= 80 then CreateColor(204, 255, 204) else # Pre_Cyan
    if pIntermediate <= 20 then Color.RED else
    if pIntermediate > pIntermediate[1] then CreateColor(0, 165, 0) else # LabelGreen
    if pIntermediate < pIntermediate[1] then Color.RED else Color.LIGHT_GRAY
);

# MACD_BB
input BBlength = 15;
input BBNum_Dev = 1.0;
input MACDfastLength = 12;
input MACDslowLength = 26;
input fastLengthMACD = 12;
input slowLengthMACD = 26;
input MACDLength = 25;
input averageTypeMACD = AverageType.WEIGHTED;
input showBreakoutSignals = no;

def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);
plot MACD_Dots = MACD_Data;
plot MACD_Line = MACD_Data;

plot BB_Upper = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).UpperBand;
plot BB_Lower = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).Lowerband;
plot BB_Midline = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).MidLine;

BB_Upper.SetDefaultColor(Color.RED);
BB_Lower.SetDefaultColor(Color.GREEN);
BB_Midline.SetDefaultColor(Color.LIGHT_RED);
BB_Midline.SetStyle(Curve.FIRM);

MACD_Line.AssignValueColor(
    if MACD_Line > MACD_Line[1] and MACD_Line >= BB_Upper then Color.GREEN
    else if MACD_Line < MACD_Line[1] and MACD_Line >= BB_Upper then Color.DARK_GREEN
    else if MACD_Line < MACD_Line[1] and MACD_Line <= BB_Lower then Color.RED else
    if MACD_Line > MACD_Line[1] and MACD_Line <= BB_Lower then Color.DARK_RED
    else Color.GRAY
);
MACD_Line.SetLineWeight(1);

MACD_Dots.AssignValueColor(
    if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then Color.GREEN
    else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then Color.DARK_GREEN
    else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then Color.RED
    else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then Color.DARK_RED
    else Color.GRAY
);
MACD_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACD_Dots.SetLineWeight(1);

AddLabel(yes,
    "Trend " +
    if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then "Bullish"
    else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then "Falling"
    else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then "Bearish"
    else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then "Rising"
    else "Neutral",
    if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then Color.GREEN
    else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then Color.DARK_GREEN
    else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then Color.RED
    else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then Color.DARK_RED
    else Color.GRAY
);

# Keltner Channels
input factor = 1.5;
input length = 20;
input averageType = AverageType.EXPONENTIAL;
input trueRangeAverageType = AverageType.EXPONENTIAL;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, close, length);
def Upper_Band = average + shift;
def Lower_Band = average - shift;

# Bollinger Bands

input BBLength2 = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input bb_averageType = AverageType.SIMPLE;

def sDev = StDev(data = close, length = BBLength2);
def MidLine = MovingAverage(bb_averageType, data = close, length = BBLength2);
def LowerBand = MidLine + Num_Dev_Dn * sDev;
def UpperBand = MidLine + Num_Dev_up * sDev;

# BB Cloud

AddCloud(if UpperBand <= Upper_Band and LowerBand >= Lower_Band then BB_Upper else BB_Lower, BB_Lower, Color.YELLOW);
AddCloud(BB_Upper, BB_Lower, Color.LIGHT_RED);

# BB Alert

input BBCrossFromAboveAlert = {default "Zero", "Lower", "Middle", "Upper"};
input BBCrossFromBelowAlert = {default "Zero", "Lower", "Middle", "Upper"};

def BBCrossFromAboveVal = if BBCrossFromAboveAlert == BBCrossFromAboveAlert.Lower then BB_Lower
                          else if BBCrossFromAboveAlert == BBCrossFromAboveAlert.Upper then BB_Upper
                          else 0;
def BBCrossFromBelowVal = if BBCrossFromBelowAlert == BBCrossFromBelowAlert.Lower then BB_Lower
                          else if BBCrossFromBelowAlert == BBCrossFromBelowAlert.Upper then BB_Upper
                          else 0;

Alert(MACD_Line crosses above BBCrossFromBelowVal, "Time to Buy", Alert.BAR, Sound.Chimes);
Alert(MACD_Line crosses below BBCrossFromBelowVal, "Time to Sell", Alert.BAR, Sound.Bell);

# RSI/STOCASTIC/MACD CONFLUENCE COMBO

def Value = MovingAverage(averageTypeMACD, close, fastLengthMACD) - MovingAverage(averageTypeMACD, close, slowLengthMACD);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);

plot Diff = Value - Avg;
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(4);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(
    if Diff >= 0 then
        if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down")
    else
        if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up")
);

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

plot UpSignalMACD = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
UpSignalMACD.SetDefaultColor(Color.UPTICK);
UpSignalMACD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignalMACD.SetHiding(!showBreakoutSignals);

plot DownSignalMACD = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
DownSignalMACD.SetDefaultColor(Color.DOWNTICK);
DownSignalMACD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignalMACD.SetHiding(!showBreakoutSignals);

input lengthRSI = 7;
input averageTypeRSI = AverageType.EXPONENTIAL;

def NetChgAvg = MovingAverage(averageTypeRSI, close - close[1], lengthRSI);
def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(close - close[1]), lengthRSI);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);

input KPeriod = 5;
input DPeriod = 3;
input averageTypeStoch = AverageType.WILDERS;

def SlowK = reference StochasticFull(80, 20, KPeriod, DPeriod, high, low, close, 3, averageTypeStoch).FullK;
def SlowD = reference StochasticFull(80, 20, KPeriod, DPeriod, high, low, close, 3, averageTypeStoch).FullD;

def rsiGreen = if RSI >= 50 then 1 else Double.NaN;
def rsiRed = if RSI < 50 then 1 else Double.NaN;
def stochGreen = if SlowK >= 50 then 1 else Double.NaN;
def stochRed = if SlowK < 50 then 1 else Double.NaN;
def macdGreen = if Value > Avg then 1 else Double.NaN;
def macdRed = if Value < Avg then 1 else Double.NaN;

input paintBars = yes;
AssignPriceColor(
    if paintBars and RSI >= 50 and SlowK >= 50 and Value > Avg then Color.GREEN
    else if paintBars and RSI < 50 and SlowK < 50 and Value < Avg then Color.RED
    else if paintBars then Color.DARK_GRAY
    else Color.CURRENT
);

# Shade areas based on criteria; adjust as needed

AddCloud(
    if rsiGreen and stochGreen and macdGreen then Double.POSITIVE_INFINITY else Double.NaN,
    if rsiGreen and stochGreen then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN
);
AddCloud(
    if rsiRed and stochRed and macdRed then Double.POSITIVE_INFINITY else Double.NaN,
    if rsiRed and stochRed then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_RED
);

# Balance of Power

input EMA = 20;
input TEMA = 20;

def THL = If(high != low, high - low, 0.01);
def BullOpen = (high - open) / THL;
def BearOpen = (open - low) / THL;
def BullClose = (close - low) / THL;
def BearClose = (high - close) / THL;
def BullOC = If(close > open, (close - open) / THL, 0);
def BearOC = If(open > close, (open - close) / THL, 0);
def BullReward = (BullOpen + BullClose + BullOC) / 1;
def BearReward = (BearOpen + BearClose + BearOC) / 1;

def BOP = BullReward - BearReward;
def SmoothBOP = ExpAverage(BOP, EMA);
def xPrice = SmoothBOP;
def xEMA1 = ExpAverage(SmoothBOP, TEMA);
def xEMA2 = ExpAverage(xEMA1, TEMA);
def xEMA3 = ExpAverage(xEMA2, TEMA);
def nRes = 3 * xEMA1 - 3 * xEMA2 + xEMA3;

def SmootherBOP = nRes;
def s1 = SmoothBOP;
def s2 = SmootherBOP;
def s3 = SmootherBOP[2];

def BOPshort = s2 < s3 and s2[1] > s3[1];
def BOPlong = s2 > s3 and s2[1] < s3[1];

# RSI IFT

def over_Bought = .5;
def over_Sold = -.5;

def R = reference RSI(5, close) - 50;
def AvgRSI = MovingAverage(AverageType.Exponential,R,9);
def inverseRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1);
def RSI_IFT_Buy =  (inverseRSI > 0) and (inverseRSI[1] < 0);
def RSI_IFT_Sell = (inverseRSI[1] > 0) and (inverseRSI < 0);

# Vertical Buy/Sell Signals

input buySellStrategy = { "BalanceOfPower", default "RSI_IFT" };

AddVerticalLine(if buySellStrategy == buySellStrategy.BalanceOfPower then BOPshort else RSI_IFT_Sell,
    close, Color.RED, Curve.SHORT_DASH);
AddVerticalLine(if buySellStrategy == buySellStrategy.BalanceOfPower then BOPlong else RSI_IFT_Buy,
    close, Color.GREEN, Curve.SHORT_DASH);

# P/L Statement

input PandL_Label = No;
input NumOfShares = 1;

Assert(NumOfShares >= 1, "Number of Shares needs to be equal or grater than 1");

def orderDir =  CompoundValue(1,
                        if buySellStrategy == buySellStrategy.BalanceOfPower then
                            if BOPlong then 1 else if BOPShort then -1 else orderDir[1]
                        else
                            if RSI_IFT_Buy then 1 else if RSI_IFT_Sell then -1 else orderDir[1]
                , 0);
def isOrder = orderDir crosses 0;
def orderCount = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then orderCount[1] + 1 else orderCount[1], 0);
def noBar = IsNaN(open[-1]);
def orderPrice = if isOrder then if noBar then close else open[-1] else orderPrice[1];
def profitLoss = if !isOrder or orderCount == 1 then 0
                else if orderDir > 0 then orderPrice[1] - orderPrice
                else if orderDir < 0 then orderPrice - orderPrice[1]
                else 0;
def profitLossSum = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then profitLossSum[1] + profitLoss else profitLossSum[1], 0);
def orderWinners = CompoundValue(1, if IsNaN(isOrder) then orderWinners[1] else if orderCount > 1 and profitLoss > 0 then orderWinners[1] + 1 else orderWinners[1], 0);

AddLabel(PandL_Label,
    orderCount + " orders (" + AsPercent(orderWinners / orderCount) + ") | P/L " + AsDollars ((profitLossSum / TickSize()) * TickValue() * NumOfShares),
    if profitLossSum > 0 then Color.GREEN else if profitLossSum < 0 then Color.RED else Color.GRAY
);
The macd bollinger band study here looks so similar to fw_dpo_mobo. Could it be replaced with that as it more precise. Also why is the macd length preferred as 25?
 
The macd bollinger band study here looks so similar to fw_dpo_mobo. Could it be replaced with that as it more precise.

This morning I watched the fw_dpo_mobo on my charts, mostly 15 min timeframe. What did I miss that makes it superior to the MACD_BB? From what I saw, the MACD_BB kept me from taking false fw_dpo_mobo signals. The latter was printing signal arrows while the MACD_BB dots were grayed out and signaling no trade. When the fw_dpo_mobo did give accurate signals, sometimes they came at the same time as the MACD_BB. Sometimes the MACD_BB was a candle or two earlier.

Not trying to be critical, @swazz. Just wondering what did I miss that is so appealing about the fw_dpo_mobo?
 
Can you please make this into a shared link so we can just import into TOS

In my not-so-humble opinion, the scanner is the hardest part of TOS to learn. If you spend a few minutes reading the last 2 pages of this thread and then play around inside the scanner testing various functions, you'll learn a skill that will serve you as long as you use TOS. Hope that didn't sound snotty because it wasn't intended that way.

Here's the easiest way I know to set up a scan for the Balanced BB Breakout indicator. Others may have better suggestions for you.

1- Copy the Balanced BB Breakout Scanner code @barbaros provided here.

2- Open TOS and click the studies icon. Select "create" to create a new indicator.

3- Delete the "plot Data = close" that appears on line one, then paste the code you copied from step 1.

4- Delete "NewStudy1" and give the study a meaningful name that you will remember as a code for scanning. You can see in the image below that I named mine "Balanced_BB_Scan_Beta." Click OK to close the window.

5- Open your scan tab. (No need to plot your newly created study on your chart). ADXCrossover will appear as the default scan study. Select "custom" from the dropdown box and then select the study you just created from @barbaros' scan code.

6- Make dropdown selections according to criteria you wish to scan for.

If you are scanning for signals from the 3 strategies, select "StrategyArrow" as the plot, then select one of the strategies you wish to scan for. These strategies are at the bottom of the image inside the yellow oval. In the image, the RSI_IFT signal has been selected. Next, select "is not equal to" zero. If you want to scan for all 3 strategies, you need to run an instance of the code for each strategy**. The same is true if you want to scan for signals on multiple timeframes. In this post, you can see a scan for FST and RSI_IMT on 30 min and daily timeframes. That scan will return results only if both strategies are firing on both timeframes.

Finally, be certain that you have selected "all of the following" under the "add condition group," otherwise the scan will pick up some or none of your criteria.

Best wishes and happy trading.


**I should note that you can select all three strategies in one instance of the scan and get results where all 3 strategies are firing. The reason I don't do it that way is because some of the signals may be "old." I found by trial and error that running an instance of code for each strategy did a better job of returning symbols where signals fired at or near the same time. You can try running the scan each way to see which results are better for your style of trading.
 
Last edited:
This morning I watched the fw_dpo_mobo on my charts, mostly 15 min timeframe. What did I miss that makes it superior to the MACD_BB? From what I saw, the MACD_BB kept me from taking false fw_dpo_mobo signals. The latter was printing signal arrows while the MACD_BB dots were grayed out and signaling no trade. When the fw_dpo_mobo did give accurate signals, sometimes they came at the same time as the MACD_BB. Sometimes the MACD_BB was a candle or two earlier.

Not trying to be critical, @swazz. Just wondering what did I miss that is so appealing about the fw_dpo_mobo?
May be I was using different settings on macd length that made the difference. which one to use? 25 0r 9? I see fw__dpo_mobo is more sensitive with dpo moving up and down although its above bb_upper. macd stays less sensitive which can be better.
 
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
436 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