It would sure help me and other new traders I would imagine.A better approach would be to have a label that showed when all the strategies agree.
It would sure help me and other new traders I would imagine.A better approach would be to have a label that showed when all the strategies agree.
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.
A label would be great. On the other hand, sometimes one of the strategies gives an early warning that something is about to change. I can see with lines plotted which strat is giving me the early warning. Or if Balance of Power is throwing off a lot of signals, we're probably in chop.Love the way you put all three strategies up on your screen. A better approach would be to have a label that showed when all the strategies agree.
Lines would cloud the playing field. but maybe a label that started at one color once one strategy fires and then turns another color at second confirmation then the final color when they are all in confluence. and a exit label as well might be a good idea?A label would be great. On the other hand, sometimes one of the strategies gives an early warning that something is about to change. I can see with lines plotted which strat is giving me the early warning. Or if Balance of Power is throwing off a lot of signals, we're probably in chop.
I like being able to tell at one glance how the strategies agree or not. Would dots instead of lines work? Something like @HighBredCloud posted in the bottom-most indicator here? Instead of plotting different timeframes as in the @HighBredCloud example, could the most recent signal for each strategy of the current timeframe be plotted on top of each other in this way?Lines would cloud the playing field. but maybe a label that started at one color once one strategy fires and then turns another color at second confirmation then the final color when they are all in confluence. and a exit label as well might be a good idea?
what does the InSync tell you?
@Trader Raider......Please dont take this the wrong way, but personally I find that approach to be ugly and confusing. Thats why I mentioned maybe two labels, there are other ways like a set of dots that only appear when they are in confluence that are color coded at the bottom row of the indicator etc. I will think on it and try to code a little solution. Not sure if this indicator is getting to complex of not. But I will possibly give it a shot to gain some experience.I like being able to tell at one glance how the strategies agree or not. Would dots instead of lines work? Something like @HighBredCloud posted in the bottom-most indicator here? Instead of plotting different timeframes as in the @HighBredCloud example, could the most recent signal for each strategy of the current timeframe be plotted on top of each other in this way?
With it at 50 from what I read Values higher or equal to 55 are considered to be high extreme levels. (short) and Values lower or equal than -55 are considered to be low extreme levels. (long). You were talking about those indicators being in alignment. Just trying to get your point of view of what this chart would be telling your. Just trying to learn and get another traders view point on what the indicators would be telling him or her. Well got hit the hay 4am comes early... Thanks for all your help..Ahh, I reversed the colors so it was more intuitive. I went into the code and reversed the red to green and vice versa.
Check out this trend to help you post pics on the forum. This tutorial is out of date but should help. https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/#post-1609What's your take on this @Trader Raider Even tho the MACDBB just crossed zero what does the InSync tell you?
My first time posting an image is there a certain size that it should be?
The Pic Below had the FibonacciSuperTrend Selected
Pic Below was using RSI_IFT
I believe this pic was 640x480
No problem, @Chuck! I like the indicator as is. I will probably continue to plot the vertical lines because they show price and time the signal fired. Please don't consider the dots a request for a change. I said it only because it would take less space to show multiple signals.@Trader Raider......Please dont take this the wrong way, but personally I find that approach to be ugly and confusing. Thats why I mentioned maybe two labels, there are other ways like a set of dots that only appear when they are in confluence that are color coded at the bottom row of the indicator etc. I will think on it and try to code a little solution. Not sure if this indicator is getting to complex of not. But I will possibly give it a shot to gain some experience.
No problem. I’ll post it shortly.@barbaros, I'm not a coder, so that would be much appreciated. THANK YOU! My brain doesn't process clouds and ribbons very well. I have to make it simple to tell when at least 2 strategies, and preferably all 3, are in alignment.
Thanks again to everyone smart enough to do the coding on this thread.
Try using https://imgur.com edit this post....I think photos added use up too much server space. After you copy the links paste them and repost.What's your take on this @Trader Raider Even tho the MACDBB just crossed zero what does the InSync tell you?
My first time posting an image is there a certain size that it should be?
The Pic Below had the FibonacciSuperTrend Selected
Pic Below was using RSI_IFT
I believe this pic was 640x480
# Balanced BB Breakout Indicator
# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Author not responsible for errors or use of tool.
# v1.2 - Assembled by Chuck Edwards
# v2.0 - Barbaros - cleanup
# v2.1 - Barbaros - added RSI IFT, NumberOfShares, BB crossing options
# v2.2 - Barbaros - fixed PnL issues and removed intraDay filter
# v2.3 - Barbaros - changed input and variable names, RSM is re-done
# v2.4 - Barbaros - removed PnL, added strategy signal arrows and alerts,
# added Fibonacci SuperTrend, added unified bar color selection
# beta - Chuck - added divergence and squeeze label, added squeeze alert
# Barbaros - cleanup, changed divergance to text, show stoch labels all the time
# Barbaros - added trend squeeze label for BB, added alerts for Stoch Scalper
# Barbaros - added options to hide clouds and labels
declare lower;
input ShowMarketForecastLabel = yes;
input ShowMACDBBLabel = yes;
input ShowMACDBBCloud = yes;
input ShowBBSqueezeLabel = yes;
input ShowBBSqueezeCloud = yes;
input ShowRSMCloud = yes;
input ShowHMALabel = yes;
input ShowSTOCHSCALPERVolumeLabel = yes;
input ShowSTOCHSCALPERSqueezeLabel = yes;
input ShowBullBearVerticalLines = yes;
### 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 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
);
### 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);
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 "Falling"
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 "Rising"
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
);
### Keltner Channels
input Keltner_Factor = 1.5;
input Keltner_length = 20;
input Keltner_AverageType = AverageType.EXPONENTIAL;
input Keltner_TrueRangeAverageType = AverageType.EXPONENTIAL;
def Keltner_Shift = Keltner_Factor * MovingAverage(Keltner_TrueRangeAverageType, TrueRange(high, close, low), Keltner_length);
def Keltner_Average = MovingAverage(Keltner_AverageType, close, Keltner_length);
def Keltner_Upper_Band = Keltner_Average + Keltner_Shift;
def Keltner_Lower_Band = Keltner_Average - Keltner_Shift;
### Bollinger Bands
input BB_Length = 20;
input BB_NumDevDn = -2.0;
input BB_NumDevUp = 2.0;
input BB_AverageType = AverageType.SIMPLE;
def BB_SDev = StDev(data = close, length = BB_Length);
def BB_MidLine = MovingAverage(BB_AverageType, data = close, length = BB_Length);
def BB_LowerBand = BB_MidLine + BB_NumDevDn * BB_SDev;
def BB_UpperBand = BB_MidLine + BB_NumDevUp * BB_SDev;
# BB Cloud
AddCloud(if ShowBBSqueezeCloud and BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.YELLOW);
AddCloud(if ShowMACDBBCloud then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.LIGHT_RED);
AddLabel(ShowBBSqueezeLabel, "Trend Squeeze", if BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then Color.WHITE else Color.GRAY);
### 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_ORANGE
else Color.RED
else
if HMA_divergence[1] < HMA_divergence then Color.DARK_GREEN
else Color.GREEN
);
### Stocastic Scalper
input STOCHSCALPER_Period = 21;
input STOCHSCALPER_PeriodEMA = 13;
input STOCHSCALPER_VolumePeriod = 60;
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_r = Highest(STOCHSCALPER_hSS, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period);
def STOCHSCALPER_p1 = (STOCHSCALPER_cSS - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period)) / STOCHSCALPER_r;
def STOCHSCALPER_K = ExpAverage(STOCHSCALPER_p1, STOCHSCALPER_PeriodEMA);
def STOCHSCALPER_sSS = Highest(STOCHSCALPER_K, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period);
def STOCHSCALPER_p3 = (STOCHSCALPER_K - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period)) / STOCHSCALPER_sSS;
def STOCHSCALPER_D = ExpAverage(STOCHSCALPER_p3, STOCHSCALPER_PeriodEMA);
def STOCHSCALPER_Min = LowestAll(STOCHSCALPER_K);
def STOCHSCALPER_Max = HighestAll(STOCHSCALPER_K);
def STOCHSCALPER_vS = Highest(volume, STOCHSCALPER_VolumePeriod) - Lowest(volume, STOCHSCALPER_VolumePeriod);
def STOCHSCALPER_vK = (volume - Lowest(volume, STOCHSCALPER_VolumePeriod)) / STOCHSCALPER_vS;
def STOCHSCALPER_vP = if STOCHSCALPER_vK > .7 then 1 else Double.NaN;
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 0 else Double.NaN;
AddLabel(ShowSTOCHSCALPERVolumeLabel, "Scalper Volume", if !IsNaN(STOCHSCALPER_vP) then Color.WHITE else Color.GRAY);
AddLabel(ShowSTOCHSCALPERSqueezeLabel, "Scalper Squeeze", if !IsNaN(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" };
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 = { "BalanceOfPower", "FibonacciSuperTrend", default "RSI_IFT" };
def BullBear_Buy = if BullBear == BullBear.BalanceOfPower then BOP_Direction == 1
else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == 1
else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == 1
else no;
def BullBear_Sell = if BullBear == BullBear.BalanceOfPower then BOP_Direction == -1
else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == -1
else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == -1
else no;
AddVerticalLine(ShowBullBearVerticalLines and BullBear_Buy and !BullBear_Buy[1], close, Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(ShowBullBearVerticalLines and BullBear_Sell and !BullBear_Sell[1], 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(BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band, "Balanced BB Squeeze", Alert.BAR, Sound.DING);
Alert(IsNaN(STOCHSCALPER_vP[1]) and !IsNaN(STOCHSCALPER_vP), "Scalper Volume", Alert.BAR, Sound.DING);
Alert(IsNaN(STOCHSCALPER_squeeze[1]) and !IsNaN(STOCHSCALPER_squeeze), "Scalper Squeeze", Alert.BAR, Sound.DING);
Updated the main page with this improved beta! Thanks @barbaros, will have to buy you a fish sandwich someday!!!Here is an update. @Chuck I think it is low risk for bugs, so we can post it on the first page.
Notice the new "Show" inputs. You can hide all labels and clouds. Plots and alerts can be configured if you scoll all the way down.
Happy trading tomorrow.
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 # beta - Chuck - added divergence and squeeze label, added squeeze alert # Barbaros - cleanup, changed divergance to text, show stoch labels all the time # Barbaros - added trend squeeze label for BB, added alerts for Stoch Scalper # Barbaros - added options to hide clouds and labels declare lower; input ShowMarketForecastLabel = yes; input ShowMACDBBLabel = yes; input ShowMACDBBCloud = yes; input ShowBBSqueezeLabel = yes; input ShowBBSqueezeCloud = yes; input ShowRSMCloud = yes; input ShowHMALabel = yes; input ShowSTOCHSCALPERVolumeLabel = yes; input ShowSTOCHSCALPERSqueezeLabel = yes; input ShowBullBearVerticalLines = yes; ### 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 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 ); ### 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); 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 "Falling" 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 "Rising" 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 ); ### Keltner Channels input Keltner_Factor = 1.5; input Keltner_length = 20; input Keltner_AverageType = AverageType.EXPONENTIAL; input Keltner_TrueRangeAverageType = AverageType.EXPONENTIAL; def Keltner_Shift = Keltner_Factor * MovingAverage(Keltner_TrueRangeAverageType, TrueRange(high, close, low), Keltner_length); def Keltner_Average = MovingAverage(Keltner_AverageType, close, Keltner_length); def Keltner_Upper_Band = Keltner_Average + Keltner_Shift; def Keltner_Lower_Band = Keltner_Average - Keltner_Shift; ### Bollinger Bands input BB_Length = 20; input BB_NumDevDn = -2.0; input BB_NumDevUp = 2.0; input BB_AverageType = AverageType.SIMPLE; def BB_SDev = StDev(data = close, length = BB_Length); def BB_MidLine = MovingAverage(BB_AverageType, data = close, length = BB_Length); def BB_LowerBand = BB_MidLine + BB_NumDevDn * BB_SDev; def BB_UpperBand = BB_MidLine + BB_NumDevUp * BB_SDev; # BB Cloud AddCloud(if ShowBBSqueezeCloud and BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.YELLOW); AddCloud(if ShowMACDBBCloud then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.LIGHT_RED); AddLabel(ShowBBSqueezeLabel, "Trend Squeeze", if BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then Color.WHITE else Color.GRAY); ### 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_ORANGE else Color.RED else if HMA_divergence[1] < HMA_divergence then Color.DARK_GREEN else Color.GREEN ); ### Stocastic Scalper input STOCHSCALPER_Period = 21; input STOCHSCALPER_PeriodEMA = 13; input STOCHSCALPER_VolumePeriod = 60; 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_r = Highest(STOCHSCALPER_hSS, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period); def STOCHSCALPER_p1 = (STOCHSCALPER_cSS - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period)) / STOCHSCALPER_r; def STOCHSCALPER_K = ExpAverage(STOCHSCALPER_p1, STOCHSCALPER_PeriodEMA); def STOCHSCALPER_sSS = Highest(STOCHSCALPER_K, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period); def STOCHSCALPER_p3 = (STOCHSCALPER_K - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period)) / STOCHSCALPER_sSS; def STOCHSCALPER_D = ExpAverage(STOCHSCALPER_p3, STOCHSCALPER_PeriodEMA); def STOCHSCALPER_Min = LowestAll(STOCHSCALPER_K); def STOCHSCALPER_Max = HighestAll(STOCHSCALPER_K); def STOCHSCALPER_vS = Highest(volume, STOCHSCALPER_VolumePeriod) - Lowest(volume, STOCHSCALPER_VolumePeriod); def STOCHSCALPER_vK = (volume - Lowest(volume, STOCHSCALPER_VolumePeriod)) / STOCHSCALPER_vS; def STOCHSCALPER_vP = if STOCHSCALPER_vK > .7 then 1 else Double.NaN; 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 0 else Double.NaN; AddLabel(ShowSTOCHSCALPERVolumeLabel, "Scalper Volume", if !IsNaN(STOCHSCALPER_vP) then Color.WHITE else Color.GRAY); AddLabel(ShowSTOCHSCALPERSqueezeLabel, "Scalper Squeeze", if !IsNaN(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" }; 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 = { "BalanceOfPower", "FibonacciSuperTrend", default "RSI_IFT" }; def BullBear_Buy = if BullBear == BullBear.BalanceOfPower then BOP_Direction == 1 else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == 1 else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == 1 else no; def BullBear_Sell = if BullBear == BullBear.BalanceOfPower then BOP_Direction == -1 else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == -1 else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == -1 else no; AddVerticalLine(ShowBullBearVerticalLines and BullBear_Buy and !BullBear_Buy[1], close, Color.GREEN, Curve.SHORT_DASH); AddVerticalLine(ShowBullBearVerticalLines and BullBear_Sell and !BullBear_Sell[1], 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(BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band, "Balanced BB Squeeze", Alert.BAR, Sound.DING); Alert(IsNaN(STOCHSCALPER_vP[1]) and !IsNaN(STOCHSCALPER_vP), "Scalper Volume", Alert.BAR, Sound.DING); Alert(IsNaN(STOCHSCALPER_squeeze[1]) and !IsNaN(STOCHSCALPER_squeeze), "Scalper Squeeze", Alert.BAR, Sound.DING);
Updated the main page with this improved beta! Thanks @barbaros, will have to buy you a fish sandwich someday!!!
Amazingly super pretty!!!Wow! This thing is becoming very pretty!
# Balanced BB Breakout Indicator
# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Author not responsible for errors or use of tool.
# v1.2 - Assembled by Chuck Edwards
# v2.0 - Barbaros - cleanup
# v2.1 - Barbaros - added RSI IFT, NumberOfShares, BB crossing options
# v2.2 - Barbaros - fixed PnL issues and removed intraDay filter
# v2.3 - Barbaros - changed input and variable names, RSM is re-done
# v2.4 - Barbaros - removed PnL, added strategy signal arrows and alerts,
# added Fibonacci SuperTrend, added unified bar color selection
# beta - Chuck - added divergence and squeeze label, added squeeze alert
# Barbaros - cleanup, changed divergance to text, show stoch labels all the time
# Barbaros - added trend squeeze label for BB, added alerts for Stoch Scalper
# Barbaros - added options to hide clouds and labels
# Barbaros - changed trend and divergence colors and text to match
declare lower;
input ShowMarketForecastLabel = yes;
input ShowMACDBBLabel = yes;
input ShowMACDBBCloud = yes;
input ShowBBSqueezeLabel = yes;
input ShowBBSqueezeCloud = yes;
input ShowRSMCloud = yes;
input ShowHMALabel = yes;
input ShowSTOCHSCALPERVolumeLabel = yes;
input ShowSTOCHSCALPERSqueezeLabel = yes;
input ShowBullBearVerticalLines = yes;
### 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 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
);
### 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);
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
);
### Keltner Channels
input Keltner_Factor = 1.5;
input Keltner_length = 20;
input Keltner_AverageType = AverageType.EXPONENTIAL;
input Keltner_TrueRangeAverageType = AverageType.EXPONENTIAL;
def Keltner_Shift = Keltner_Factor * MovingAverage(Keltner_TrueRangeAverageType, TrueRange(high, close, low), Keltner_length);
def Keltner_Average = MovingAverage(Keltner_AverageType, close, Keltner_length);
def Keltner_Upper_Band = Keltner_Average + Keltner_Shift;
def Keltner_Lower_Band = Keltner_Average - Keltner_Shift;
### Bollinger Bands
input BB_Length = 20;
input BB_NumDevDn = -2.0;
input BB_NumDevUp = 2.0;
input BB_AverageType = AverageType.SIMPLE;
def BB_SDev = StDev(data = close, length = BB_Length);
def BB_MidLine = MovingAverage(BB_AverageType, data = close, length = BB_Length);
def BB_LowerBand = BB_MidLine + BB_NumDevDn * BB_SDev;
def BB_UpperBand = BB_MidLine + BB_NumDevUp * BB_SDev;
# BB Cloud
AddCloud(if ShowBBSqueezeCloud and BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.YELLOW);
AddCloud(if ShowMACDBBCloud then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.LIGHT_RED);
AddLabel(ShowBBSqueezeLabel, "Trend Squeeze", if BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then Color.WHITE else Color.GRAY);
### 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
input STOCHSCALPER_Period = 21;
input STOCHSCALPER_PeriodEMA = 13;
input STOCHSCALPER_VolumePeriod = 60;
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_r = Highest(STOCHSCALPER_hSS, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period);
def STOCHSCALPER_p1 = (STOCHSCALPER_cSS - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period)) / STOCHSCALPER_r;
def STOCHSCALPER_K = ExpAverage(STOCHSCALPER_p1, STOCHSCALPER_PeriodEMA);
def STOCHSCALPER_sSS = Highest(STOCHSCALPER_K, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period);
def STOCHSCALPER_p3 = (STOCHSCALPER_K - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period)) / STOCHSCALPER_sSS;
def STOCHSCALPER_D = ExpAverage(STOCHSCALPER_p3, STOCHSCALPER_PeriodEMA);
def STOCHSCALPER_Min = LowestAll(STOCHSCALPER_K);
def STOCHSCALPER_Max = HighestAll(STOCHSCALPER_K);
def STOCHSCALPER_vS = Highest(volume, STOCHSCALPER_VolumePeriod) - Lowest(volume, STOCHSCALPER_VolumePeriod);
def STOCHSCALPER_vK = (volume - Lowest(volume, STOCHSCALPER_VolumePeriod)) / STOCHSCALPER_vS;
def STOCHSCALPER_vP = if STOCHSCALPER_vK > .7 then 1 else Double.NaN;
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 0 else Double.NaN;
AddLabel(ShowSTOCHSCALPERVolumeLabel, "Scalper Volume", if !IsNaN(STOCHSCALPER_vP) then Color.WHITE else Color.GRAY);
AddLabel(ShowSTOCHSCALPERSqueezeLabel, "Scalper Squeeze", if !IsNaN(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" };
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 = { "BalanceOfPower", "FibonacciSuperTrend", default "RSI_IFT" };
def BullBear_Buy = if BullBear == BullBear.BalanceOfPower then BOP_Direction == 1
else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == 1
else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == 1
else no;
def BullBear_Sell = if BullBear == BullBear.BalanceOfPower then BOP_Direction == -1
else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == -1
else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == -1
else no;
AddVerticalLine(ShowBullBearVerticalLines and BullBear_Buy and !BullBear_Buy[1], close, Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(ShowBullBearVerticalLines and BullBear_Sell and !BullBear_Sell[1], 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(BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band, "Balanced BB Squeeze", Alert.BAR, Sound.DING);
Alert(IsNaN(STOCHSCALPER_vP[1]) and !IsNaN(STOCHSCALPER_vP), "Scalper Volume", Alert.BAR, Sound.DING);
Alert(IsNaN(STOCHSCALPER_squeeze[1]) and !IsNaN(STOCHSCALPER_squeeze), "Scalper Squeeze", Alert.BAR, Sound.DING);
Great minds think alike, I traded the /es and did great this morning as well. I will update now. I am loving this indicator.Guys, I had a 9.5 pt trade with /ES this morning and made a minor modification. The "Trend" and "Divergence" labels have the same states but had different colors and text. They match now.
@Chuck quick update.
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 # beta - Chuck - added divergence and squeeze label, added squeeze alert # Barbaros - cleanup, changed divergance to text, show stoch labels all the time # Barbaros - added trend squeeze label for BB, added alerts for Stoch Scalper # Barbaros - added options to hide clouds and labels # Barbaros - changed trend and divergence colors and text to match declare lower; input ShowMarketForecastLabel = yes; input ShowMACDBBLabel = yes; input ShowMACDBBCloud = yes; input ShowBBSqueezeLabel = yes; input ShowBBSqueezeCloud = yes; input ShowRSMCloud = yes; input ShowHMALabel = yes; input ShowSTOCHSCALPERVolumeLabel = yes; input ShowSTOCHSCALPERSqueezeLabel = yes; input ShowBullBearVerticalLines = yes; ### 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 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 ); ### 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); 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 ); ### Keltner Channels input Keltner_Factor = 1.5; input Keltner_length = 20; input Keltner_AverageType = AverageType.EXPONENTIAL; input Keltner_TrueRangeAverageType = AverageType.EXPONENTIAL; def Keltner_Shift = Keltner_Factor * MovingAverage(Keltner_TrueRangeAverageType, TrueRange(high, close, low), Keltner_length); def Keltner_Average = MovingAverage(Keltner_AverageType, close, Keltner_length); def Keltner_Upper_Band = Keltner_Average + Keltner_Shift; def Keltner_Lower_Band = Keltner_Average - Keltner_Shift; ### Bollinger Bands input BB_Length = 20; input BB_NumDevDn = -2.0; input BB_NumDevUp = 2.0; input BB_AverageType = AverageType.SIMPLE; def BB_SDev = StDev(data = close, length = BB_Length); def BB_MidLine = MovingAverage(BB_AverageType, data = close, length = BB_Length); def BB_LowerBand = BB_MidLine + BB_NumDevDn * BB_SDev; def BB_UpperBand = BB_MidLine + BB_NumDevUp * BB_SDev; # BB Cloud AddCloud(if ShowBBSqueezeCloud and BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.YELLOW); AddCloud(if ShowMACDBBCloud then MACDBB_Upper else MACDBB_Lower, MACDBB_Lower, Color.LIGHT_RED); AddLabel(ShowBBSqueezeLabel, "Trend Squeeze", if BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band then Color.WHITE else Color.GRAY); ### 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 input STOCHSCALPER_Period = 21; input STOCHSCALPER_PeriodEMA = 13; input STOCHSCALPER_VolumePeriod = 60; 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_r = Highest(STOCHSCALPER_hSS, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period); def STOCHSCALPER_p1 = (STOCHSCALPER_cSS - Lowest(STOCHSCALPER_lSS, STOCHSCALPER_Period)) / STOCHSCALPER_r; def STOCHSCALPER_K = ExpAverage(STOCHSCALPER_p1, STOCHSCALPER_PeriodEMA); def STOCHSCALPER_sSS = Highest(STOCHSCALPER_K, STOCHSCALPER_Period) - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period); def STOCHSCALPER_p3 = (STOCHSCALPER_K - Lowest(STOCHSCALPER_K, STOCHSCALPER_Period)) / STOCHSCALPER_sSS; def STOCHSCALPER_D = ExpAverage(STOCHSCALPER_p3, STOCHSCALPER_PeriodEMA); def STOCHSCALPER_Min = LowestAll(STOCHSCALPER_K); def STOCHSCALPER_Max = HighestAll(STOCHSCALPER_K); def STOCHSCALPER_vS = Highest(volume, STOCHSCALPER_VolumePeriod) - Lowest(volume, STOCHSCALPER_VolumePeriod); def STOCHSCALPER_vK = (volume - Lowest(volume, STOCHSCALPER_VolumePeriod)) / STOCHSCALPER_vS; def STOCHSCALPER_vP = if STOCHSCALPER_vK > .7 then 1 else Double.NaN; 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 0 else Double.NaN; AddLabel(ShowSTOCHSCALPERVolumeLabel, "Scalper Volume", if !IsNaN(STOCHSCALPER_vP) then Color.WHITE else Color.GRAY); AddLabel(ShowSTOCHSCALPERSqueezeLabel, "Scalper Squeeze", if !IsNaN(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" }; 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 = { "BalanceOfPower", "FibonacciSuperTrend", default "RSI_IFT" }; def BullBear_Buy = if BullBear == BullBear.BalanceOfPower then BOP_Direction == 1 else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == 1 else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == 1 else no; def BullBear_Sell = if BullBear == BullBear.BalanceOfPower then BOP_Direction == -1 else if BullBear == BullBear.FibonacciSuperTrend then FST_Direction == -1 else if BullBear == BullBear.RSI_IFT then RSI_IFT_Direction == -1 else no; AddVerticalLine(ShowBullBearVerticalLines and BullBear_Buy and !BullBear_Buy[1], close, Color.GREEN, Curve.SHORT_DASH); AddVerticalLine(ShowBullBearVerticalLines and BullBear_Sell and !BullBear_Sell[1], 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(BB_UpperBand <= Keltner_Upper_Band and BB_LowerBand >= Keltner_Lower_Band, "Balanced BB Squeeze", Alert.BAR, Sound.DING); Alert(IsNaN(STOCHSCALPER_vP[1]) and !IsNaN(STOCHSCALPER_vP), "Scalper Volume", Alert.BAR, Sound.DING); Alert(IsNaN(STOCHSCALPER_squeeze[1]) and !IsNaN(STOCHSCALPER_squeeze), "Scalper Squeeze", Alert.BAR, Sound.DING);
Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
RedK Chop & Breakout Scout V2.0 for ThinkOrSwim | Indicators | 17 | ||
G | Potential Breakout (PBO) Indicator for ThinkorSwim | Indicators | 8 | |
ThinkorSwim Stock Breakout Scanner | Indicators | 11 | ||
Potential Breakout Arrow Plots Indicator for ThinkorSwim | Indicators | 82 | ||
H | TOP Ultimate Breakout Indicator for ThinkorSwim | Indicators | 127 |
Start a new thread and receive assistance from our community.
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.
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.