B4 Balanced BB Breakout For ThinkOrSwim

Status
Not open for further replies.

Volatility Trading Range

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

Download the indicator

Everything here stays free. It wouldn't make sense or fair to anyone contributed to take all this work and monetize. Also, we will still continue contributing enhancements and more add-ons to the community here.
That all I am asking, the said New Features and Add-ons, are they meant for community or promotion of services? :)
 
We have an improved version of the mADX Add-One available. It was pointed out by one of our members that the mADX v2 worked really well on daily charts and the earlier version seemed to work better on intraday. So we can keep things more customizable and appeal to everyones trading style we decided to release a new version that is UI adjustable with note on how to use. Here you go....Enjoy
 
We have an improved version of the mADX Add-One available. It was pointed out by one of our members that the mADX v2 worked really well on daily charts and the earlier version seemed to work better on intraday. So we can keep things more customizable and appeal to everyones trading style we decided to release a new version that is UI adjustable with note on how to use. Here you go....Enjoy

Thanks Chuck for taking time to explain. BTW. in case if you are interested, here is the piece of code that can adjust the ADDON_ADX_limit automatically based on the time, yet configurable by enduser.

My Original question to you post earlier today was not doubt your intent nor to suggest there are no add-on. Your post suggested there are more add-on to come, and the question to that was are they community based? if yes, there may be few other willing to spend time on coding.


Code:
# v1.0 - chuck    - initial integration
# v2.0 - barbaros - cleanup
# v2.1 - barbaros - added adx limit

input ADDON_ADX_show = yes;
input ADDON_ADX_dmilength = 10;
input ADDON_dADX_limit = 35; #hint ADDON_ADX_limit: 25 for daily and 35 for intraday suggested
input ADDON_iADX_limit = 25;
def ADDON_ADX_limit = if GetAggregationPeriod() >= AggregationPeriod.DAY then ADDON_dADX_limit else ADDON_iADX_limit;
input ADDON_ADX_dmiaverageType = AverageType.WILDERS;

def ADDON_ADX_ADX = (DMI(ADDON_ADX_dmilength, ADDON_ADX_dmiaverageType).ADX) - 18;
def ADDON_ADX_signal = ADDON_ADX_ADX> ADDON_ADX_limit and ADDON_ADX_ADX >= 1 and ADDON_ADX_ADX < ADDON_ADX_ADX[1] and ADDON_ADX_ADX[1] > ADDON_ADX_ADX[2];

AddVerticalLine (ADDON_ADX_show and ADDON_ADX_signal, "mADX", Color.WHITE);
Alert(ADDON_ADX_signal, "mADX", Alert.BAR, Sound.Ding);
Addlabel(yes, "ADX: " + ADDON_ADX_limit , Color.Yellow);

-S
 
@SuryaKiranC Please let @Chuck or myself know how else we can clarify our position about this indicator, community and how we are fully committed to provide updates, enhancements and add-ons.
We were told in the discord, there are exclusive enhancement and Add-Ons for premium services, along with education and possibly alerts sort of. When a Screenshot was posted here, by @Chuck, it looked like there are more enhancements and Add-on(s) coming.

So, the obvious natural question I had was, the once mentioned here are they for community? if so I am interested in coding and contributing. That is all my question about. Nothing more. Not sure why am I so hard to get through with that one point in the question.

I am specifically to the screenshot posted here earlier in the day, about "New Features and Add-Ons", May be I will include the link to the post, so we can avoid any further confusion.

https://usethinkscript.com/threads/balanced-bb-breakout.5708/post-63571

-S
 
We were told in the discord, there are exclusive enhancement and Add-Ons for premium services, along with education and possibly alerts sort of. When a Screenshot was posted here, by @Chuck, it looked like there are more enhancements and Add-on(s) coming.

So, the obvious natural question I had was, the once mentioned here are they for community? if so I am interested in coding and contributing. That is all my question about. Nothing more. Not sure why am I so hard to get through with that one point in the question.

I am specifically to the screenshot posted here earlier in the day, about "New Features and Add-Ons", May be I will include the link to the post, so we can avoid any further confusion.

https://usethinkscript.com/threads/balanced-bb-breakout.5708/post-63571

-S
I have a whole list of Add-Ons.(too many for barbaros to keep up with) Each Add-On can be used as its own indicator or added on to the B4. Everything I have built I have posted to this forum for free, everything, that is barbaros has been kind enough to check. We have not released the Add-Ons in development to this forum or any other because they have not been tested and we have been to busy maintaining the community, trying to help as many people as we can. Thank you for your interest in B4.
 
Last edited:
@Chuck @barbaros Firstly, thank you so much for all your hard work and explanation on your BB Breakout indicator, truly appreciate it.

I have a question: I use the 10x bars, and in the photo below one may see that in the lower time frames the yellow bars are gray. Any idea on a reason for this? I believe the BB Breakout used is your 3d version.

Thank you.

CcdM6gA.png
 
Try this :

Its that your (Bar Color Label)Using the RSM setting, Setting the Bar Color to none, OR Rest the Script Copy and past and # out the old line

### Bar Color ######################################

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

If this don't help, you could have conflictingin the indicators. your going to have to search all you indicators for the ASSIGNEDPRICECOLOR line in your indicators, that the line that changes the bar colors. Just# them out unit you get the candle colors what. usually the control is in the lower indicators. hope it helps.
 
@Chuck @barbaros Thank you for sharing this indicator. This looks very promising.

Quick help - How can I scan for stocks for which MACDBB dotted Line turns from RED to DARK RED ?
 
@Chuck @barbaros Thank you for sharing this indicator. This looks very promising.

Quick help - How can I scan for stocks for which MACDBB dotted Line turns from RED to DARK RED ?
Yes, the scanner has been updated to support the dot changes. It is called the TrendDirection input for the scanner. Colors are numerically coded 2,1,0,-1 and 2. Join us on Discord and we can help in realtime.
 
@Chuck @barbaros Firstly, thank you so much for all your hard work and explanation on your BB Breakout indicator, truly appreciate it.

I have a question: I use the 10x bars, and in the photo below one may see that in the lower time frames the yellow bars are gray. Any idea on a reason for this? I believe the BB Breakout used is your 3d version.

Thank you.

CcdM6gA.png
Good observation. Gray bars are indecision or "not in confluence" candles. You will see them in the higher time frames as well.
 
Yes, the scanner has been updated to support the dot changes. It is called the TrendDirection input for the scanner. Colors are numerically coded 2,1,0,-1 and 2. Join us on Discord and we can help in realtime.

I am not able to join discord - "Unable to accept invite".

Found what I was looking for. By removing "=" in this Trend direction "if MACDBB_Data > MACDBB_Data[1] and MACDBB_Data <= MACDBB_Lower then -1"
 
Last edited:
hello all new here been trading for about a year now have tried all many different indicators and copied the code from here and honestly super impressed, usually trade big stock options like amzn fb tsla and love how this script reacts!!!

have any of yall combined it with a automatic fib level script or know of any??

also confused how the madx line works

so far combined it with ahull moving average on top to help me out with direction and also using someone else's script that draws trend lines and uses the 50 ema as main driver for his gold or red candles

got stopped out today for taking a trade 5 minutes in

will wait for super mtf to go all red or green next time (my super mtf will not work in any time frame over 5 minutes any pointers?)

Check out the latest addition to the mADX, I create it as an upper indicator and select the 35 setting. I use it as a trend exhaustion signal. It is not always the case but works pretty good.
 
@Trader Raider do you mind sharing your TOS workspace?

I ran this strategy on the 5min /mes and 5min /mnq and the 90 day backtests results are very promising.
Have you been using this @Ghostwar19?

I've been using the B4 indicator on /mes and /mnq the past few days and combined with volume profile concepts this thing is lethal.
Thank you @Chuck and @barbaros and everyone else involved.
What is the best way to conduct the backtesting. Are you using the P/L study and exporting to an xls? Thanks
 

Balanced BB Breakout-"B4"

rljGjEX.png


Thanks to all the talented people who have dedicated time and effort to this indicator.
All I did was see an opportunity to mix all of my favorite indicators into one great lower study that helped keep my upper chart clean and at the same time provide me with a great amount of info to trade.

I myself have only been using this for a few months, In that time it has helped me as a trader. Comments are welcome. Let me know how you use it, how it works for your trades!

This is how I like to trade this indicator and it is not to be considered trading advise. Many people are asking how I use this indicator so I decided to explain how I personally like you use this. This info is for educational purposes only. This info will be updated to reflect each new version as it evolves.
  • I usually trade in the direction of the MACDBB mid line. The trend label is synced with that and will help keep you in the right direction.
  • I like to see confirmation with the Market Forecast and the trend label. I find a neutral trend is not my friend as it usually will chop me out of profit.
  • The MACDBB Cloud in the original version incorporated the use of Keltner Channel to determine a squeeze, the newer versions employ a stocastic squeeze. A yellow (default) cloud will appear on the bands when this condition is meet. Price has a tendency to breakout after a squeeze. This is where I like to be set up waiting for an entry.
  • The Bollinger Bands when contracted show an area of consolidation or a point of equilibrium. These levels are often areas of supply and demand or support and resistance. When the band is tight and the MACDBB Dotted Line crosses over the top band It is typically a strong move to the up side, just the opposite in the inverse.
  • By default, the alerts crossing for the bands from both directions is set to zero.
  • Some people may want to enter a position upon the MACDBB dotted Line crossing the BB bands Upper, Lower, Or Middle line. You will have to play with it and figure out what works best for you. The alerts from this will not give you an absolute top or absolute bottom. But serves as a good indication of price aggregation.
  • The clouds in the background are a confluent combination of RSI, STOCASTIC and MACD. That’s why it is referred to as RSM. When the signals are confluent, they will either be Red or Green by default. When they are not in agreement it is likely you are in inflight turbulence or a change of investor sentiment.
  • For my first confirmation of a trade, I watch the MACDBB dots line. Before the line turns grey it should turn dark red or dark green. That’s when I am alerted, I use that as my lead while using this indicator.
  • When the MACDBB dots line turns gray, that is an area of indecision and as soon as that line crosses the MACDBB middle line, I look for secondary confirmation to confirm entry or exit, I do this on entries and exits.
  • For those looking to get a better exit on the RSI_IFT strategy, perhaps this will alert you, we are working on a solution now to provide a more reasonable exit for this stratigy. I have an add-on that is almost complete that will be of assistance in determining an exit, and will update you all when we finish it.
  • Personally with my risk tolerance, I find that when the MACDBB dots line turns gray when I am in a long position and crosses over the top BB line, I usually exit my position. I then wait for the pull back or a continuation. I find personally that the commission fee for exiting out ways the 100’s of dollars I risk or lose if the position changes direction at that time. I do the inverse for shorts.
THIS PORTION IS FOR THE EARLIER VERSIONS WITH THE P/L AND MACD HISTOGRAM ARROWS OPTIONS (Might be a future Add_On or even a rework once we finalize the stratigies)
  • For each instrument that I trade I can run a P/L analysis.
  • NOTE: The profit calculator uses the chart settings for bar #1 to start the strategy and calculates P/L for the amount of trades thereafter. I look at the P/L and how it differs based on changing the timeframe - so if 5m looks better than 3, I would probably go with 5m. Of course, past performance is not indicative of future results, but I like to trade what I see.
  • The first thing I do is back test it on the instrument I want to trade. Using a 1D chart with time intervals of 2m,3m,5m,10m,15m, etc. and check out the P/L to see what time frame is the most profitable, considering my risk and max drawdown. At this time, I also like to switch between the built-in strategies to see which one would have made me the most money and probably choose that one. You will not trade exactly like the strategy, but I feel it is a good start. I like to have probability in my favor. that’s why I put that strategy on my lower indicators.
  • I have all the arrows turned on in my version and I look for the arrows, or histogram, or colored cloud background, in accordance with the selected strategy entry line or my entries also considering the other signals and price indications I am getting from the candles and other indicators in my final evaluation.
Latest Version Update v2.5

Changes made to this version:

  • cleanup, changed divergance to text, show stoch labels all the time
  • added trend squeeze label for BB, added alerts for Stoch Scalper
  • added options to hide clouds and labels(thanks to the users for making this suggestion)
  • changed trend and divergence colors and text to match
  • removed volume and keltner channel studies, unified squeeze
To select the strategy you wish just navigate to your study and select the one you wish in the "bull bear" dropdown.

3f8bPLZ.png


Do some backtesting and find out what strategy works best for you, each can be used on interday, swing and long term investing. You will have to decide what strategy suits your particular risk tolerance and trading style.

INSTALLATION

https://tos.mx/FPDl0NT

1) Copy the link below:

2) Go to the main window of the TOS platform and click “Setup” followed by “Open Shared Item.”
3) An “Open Shared Item” window will pop up. Paste the link (using Control – V) into the box and click “Preview.”
4) Click “Open” and the Balanced BB Breakout script will download to your platform.
5) Click “Rename” and type in “Balanced BB Breakout”
6) Go to TOS charts: click “Studies” and “Edit Studies.” Select the “Balanced BB Breakout” study from the list of studies on the left and click “Add selected.” Click “OK” and the Balanced BB Breakout study will be applied to your chart.
--------------------------------------------------------------------------------------------------------------------------------------------


Code:
# B4 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.
# Copyright (c) 2021 B4 Signals
#
# Get support at: https://b4signals.com
# Join us at: https://discord.gg/kD3pKE2CQd
#
#
# v3.0 - barbros / chuck - official release

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

AddLabel(yes, "B4 Indicator", Color.WHITE);

### 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.DARK_GREEN else
    if pIntermediate <= 20 then Color.DARK_RED else
    if pIntermediate > pIntermediate[1] then Color.GREEN else
    if pIntermediate < pIntermediate[1] then Color.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 (reversing)"
    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 (reversing)"
    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.DARK_GRAY);
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"
            else "Bearish (reversing)"
        else
            if HMA_divergence[1] < HMA_divergence then "Bullish"
            else "Bullish (reversing)",
        if HMA_concavity < 0 then
            if HMA_divergence[1] > HMA_divergence then Color.RED
            else Color.DARK_RED
        else
            if HMA_divergence[1] < HMA_divergence then Color.GREEN
            else Color.DARK_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);

### 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_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_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!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);


---------------------------------------------------------------------------------------------------------------------------


Balanced BB Breakout Bullish/Bearish Scanner:

Due to limitations in TOS, and the complexity of the study, some features had to be omitted from the scanner.
Most options are kept. It works exactly like the chart arrows.
If you want buy signal, you set the value to 1. If you want sell signal, you set the value to -1.

Give this new version a try and let us know how it works:

Code:
#
# B4 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.
# Copyright (c) 2021 B4 Signals
#
# Get support at: https://b4signals.com
# Join us at: https://discord.gg/kD3pKE2CQd
#
#
# v3.0 - barbros / chuck - official release

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

### 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_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_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!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;

plot TrendDirection = if MACDBB_Data > MACDBB_Data[1] and MACDBB_Data >= MACDBB_Upper then 2
                    else if MACDBB_Data < MACDBB_Data[1] and MACDBB_Data >= MACDBB_Upper then 1
                    else if MACDBB_Data < MACDBB_Data[1] and MACDBB_Data <= MACDBB_Lower then -2
                    else if MACDBB_Data > MACDBB_Data[1] and MACDBB_Data <= MACDBB_Lower then -1
                    else 0;
--------------------------------------------------------------------------------------------------------------------------------------------


ADX Add-On

Here is a little something extra I was working on and barbaros fixed up for me. It is an ADX line. It is set to 35 and can be adjusted to your discretion. Just copy and paste the code adding it to the bottom of your script:
Code:
# v1.0 - chuck    - initial integration
# v2.0 - barbaros - cleanup
# v2.1 - barbaros - added adx limit

input ADDON_ADX_show = yes;
input ADDON_ADX_dmilength = 10;
input ADDON_ADX_limit = 35; #hint ADDON_ADX_limit: 25 for daily and 35 for intraday suggested
input ADDON_ADX_dmiaverageType = AverageType.WILDERS;

def ADDON_ADX_ADX = (DMI(ADDON_ADX_dmilength, ADDON_ADX_dmiaverageType).ADX) - 18;
def ADDON_ADX_signal = ADDON_ADX_ADX> ADDON_ADX_limit and ADDON_ADX_ADX >= 1 and ADDON_ADX_ADX < ADDON_ADX_ADX[1] and ADDON_ADX_ADX[1] > ADDON_ADX_ADX[2];

AddVerticalLine (ADDON_ADX_show and ADDON_ADX_signal, "mADX", Color.WHITE);
Alert(ADDON_ADX_signal, "mADX", Alert.BAR, Sound.Ding);

--------------------------------------------------------------------------------------------------------------------------------------------

Watchlist Column

Code:
# B4 Watchlist Column
#
# 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.
# Copyright (c) 2021 B4 Signals
#
# Get support at: https://b4signals.com
# Join us at: https://discord.gg/kD3pKE2CQd
#
#
# v3.0 - barbros / chuck - official release

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

### 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_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_FST or FST_Direction == 1) and
                   (!BullBear_Include_RSI_IFT or RSI_IFT_Direction == 1);
def BullBear_Sell = (!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;


AssignBackgroundColor(
    if Strategy_Buy and !Strategy_Buy[1] then Color.GREEN
    else if Strategy_Sell and !Strategy_Sell[1] then Color.RED
    else color.CURRENT
);

AddLabel(yes,
    if Strategy_Buy and !Strategy_Buy[1] then "Buy"
    else if Strategy_Sell and !Strategy_Sell[1] then "Sell"
    else if Strategy_Buy then "Long"
    else if Strategy_Sell then "Short"
    else "Neutral",

    if Strategy_Buy and !Strategy_Buy[1] then Color.BLACK
    else if Strategy_Sell and !Strategy_Sell[1] then Color.WHITE
    else if Strategy_Buy then Color.LIGHT_GREEN
    else if Strategy_Sell then Color.LIGHT_RED
    else Color.CURRENT
);
--------------------------------------------------------------------------------------------------------------------------------------------

Here is the latest beta version:

https://tos.mx/0aqdRea

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

Many thanks to all those who are contributing to this project. Again, any new versions will be posted here to cut down on any confusion.

Disclaimer:

This indicator may or may not be suitable for you, it should not be used on its own. Instead, chartists should use it in conjunction with other analysis techniques. Constructive criticism welcomed in order to improve. Please report any bugs so we can continue to improve it.
when I put it in the thinkscript editor, I get exactly one post expected...
 
All right let me know what you like and what you don’t like about the B4.. I think we’re pretty much getting settled in and have it dialed in pretty good. I have several add-ons in the works and we were just wondering what you guys like and dislike about the indicator as it is?
 
Try this link:

https://tos.mx/FPDl0NT

Let me know if this helps!
thank you for your reply. long story, but I have the study, I was talking about the scanner, I LOVE the study! But I'm having problems with installing the scanner. I've tried to find a video on how to do it, but I can't find one.... when I put the code in the thnkscripteditor, I get "exactly one post expected" ... Thank you for your hard work...
 
Status
Not open for further replies.

New Indicator: Buy the Dip

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

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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