Final Scan which includes everything :)
# Balanced BB Breakout Indicator
# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Author not responsible for errors or use of tool.
# v1.2 - Assembled by Chuck Edwards
# v2.0 - Barbaros - cleanup
# v2.1 - Barbaros - added RSI IFT, NumberOfShares, BB crossing options
# v2.2 - Barbaros - fixed PnL issues and removed intraDay filter
# v2.3 - Barbaros - changed input and variable names, RSM is re-done
# v2.4 - Barbaros - removed PnL, added strategy signal arrows and alerts,
# added Fibonacci SuperTrend, added unified bar color selection
# beta - Chuck - added divergence and squeeze label, added squeeze alert
# Barbaros - cleanup, changed divergance to text, show stoch labels all the time
# Barbaros - added trend squeeze label for BB, added alerts for Stoch Scalper
# Barbaros - added options to hide clouds and labels
# Barbaros - changed trend and divergence colors and text to match
# Barbaros - removed volume and keltner channel studies, unified squeeze
# v1.2 AspaTrader - Adapted new Indicator and added Fib series. TODO: MarketForecast
# v1.3 AspaTrader - Fixed issue with script complex or timeout
# V2.0 AspaTrade - Added signals for vertical Lines + Market Forecast + MACDBB + RSM Buy Signal + HMA Signal (55 MA) + BOP_Direction + Fibonacci Super Trend
### Market Forecast
def pIntermediate = MarketForecast().Intermediate;
def MF_SIGNAL = if pIntermediate >= 80 or pIntermediate > pIntermediate[1] then 1 else
if pIntermediate <= 20 or pIntermediate < pIntermediate[1] then 0 else -1;
### MACDBB
input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_Length = 25;
input MACDBB_BandLength = 15;
input MACDBB_NumDev = 1.0;
def MACDBB_Data = MACD(fastLength = MACDBB_FastLength, slowLength = MACDBB_SlowLength, MACDLength = MACDBB_Length);
def MACDBB_Upper = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;
def MACDBB_Lower = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;
def MACDBB_Midline = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).MidLine;
def MACDBB_Line = MACDBB_Data;
def MACDBB_SIGNAL =
if MACDBB_Line > MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper or MACDBB_Line < MACDBB_Line[1] and MACDBB_Line >= MACDBB_Upper then 1
else if MACDBB_Line < MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower or MACDBB_Line > MACDBB_Line[1] and MACDBB_Line <= MACDBB_Lower then 0
else -1;
input MACDBB_CrossFromAboveAlert = {default "Zero", "Lower", "Middle", "Upper"};
input MACDBB_CrossFromBelowAlert = {default "Zero", "Lower", "Middle", "Upper"};
def MACDBB_CrossFromAboveVal = if MACDBB_CrossFromAboveAlert == MACDBB_CrossFromAboveAlert.Lower then MACDBB_Lower
else if MACDBB_CrossFromAboveAlert == MACDBB_CrossFromAboveAlert.Upper then MACDBB_Upper
else 0;
def MACDBB_CrossFromBelowVal = if MACDBB_CrossFromBelowAlert == MACDBB_CrossFromBelowAlert.Lower then MACDBB_Lower
else if MACDBB_CrossFromBelowAlert == MACDBB_CrossFromBelowAlert.Upper then MACDBB_Upper
else 0;
def MACDBB_Buy = MACDBB_Data > MACDBB_Upper;
def MACDBB_Sell = MACDBB_Data <= MACDBB_Lower;
def MACDBB_OVERALL_SIGNAL = MACDBB_SIGNAL and MACDBB_Buy;
### RSI/STOCASTIC/MACD CONFLUENCE COMBO
def RSM_MACD_Diff = reference MACD("fast length" = 12, "slow length" = 26, "macd length" = 9).Diff;
def RSM_MACD_Diff_SIGNAL = if RSM_MACD_Diff >= 0 then
if RSM_MACD_Diff > RSM_MACD_Diff[1] then 1 else -1
else
if RSM_MACD_Diff < RSM_MACD_Diff[1] then 0 else -1;
def RSM_RSI = reference RSI(length = 7).RSI;
def RSM_Stoch_Val = 100 * (close - lowest(low, 14)) / (highest(high, 14) - lowest(low, 14));
def RSM_StochSlowK = SimpleMovingAvg(SimpleMovingAvg(RSM_Stoch_Val,3),3);
def RSM_rsiGreen = RSM_RSI >= 50;
def RSM_rsiRed = RSM_RSI < 50;
def RSM_stochGreen = RSM_StochSlowK >= 50;
def RSM_stochRed = RSM_StochSlowK < 50;
def RSM_macdGreen = RSM_MACD_Diff >= 0;
def RSM_macdRed = RSM_MACD_Diff < 0;
def RSM_Buy = RSM_rsiGreen and RSM_stochGreen and RSM_macdGreen;
def RSM_Sell = RSM_rsiRed and RSM_stochRed and RSM_macdRed;
### Divergance
input HMA_Length = 55;
input HMA_Lookback = 2;
def HMA = HullMovingAvg(price = HL2, length = HMA_Length);
def HMA_delta = HMA[1] - HMA[HMA_Lookback + 1];
def HMA_delta_per_bar = HMA_delta / HMA_Lookback;
def HMA_next_bar = HMA[1] + HMA_delta_per_bar;
def HMA_concavity = if HMA > HMA_next_bar then 1 else -1;
def HMA_MA_Max = if HMA[-1] < HMA and HMA > HMA[1] then HMA else Double.NaN;
def HMA_MA_Min = if HMA[-1] > HMA and HMA < HMA[1] then HMA else Double.NaN;
def HMA_divergence = HMA - HMA_next_bar;
def HMA_SIGNAL = if HMA_divergence[1] < HMA_divergence then 0 else if HMA_divergence[1] < HMA_divergence then 1 else 1;
### Balance of Power
input BOP_EMA_Length = 20;
input BOP_TEMA_Length = 20;
def BOP_THL = If(high != low, high - low, 0.01);
def BOP_BullOpen = (high - open) / BOP_THL;
def BOP_BearOpen = (open - low) / BOP_THL;
def BOP_BullClose = (close - low) / BOP_THL;
def BOP_BearClose = (high - close) / BOP_THL;
def BOP_BullOC = If(close > open, (close - open) / BOP_THL, 0);
def BOP_BearOC = If(open > close, (open - close) / BOP_THL, 0);
def BOP_BullReward = (BOP_BullOpen + BOP_BullClose + BOP_BullOC) / 1;
def BOP_BearReward = (BOP_BearOpen + BOP_BearClose + BOP_BearOC) / 1;
def BOP_BOP = BOP_BullReward - BOP_BearReward;
def BOP_SmoothBOP = ExpAverage(BOP_BOP, BOP_EMA_Length);
def BOP_xPrice = BOP_SmoothBOP;
def BOP_xEMA1 = ExpAverage(BOP_SmoothBOP, BOP_TEMA_Length);
def BOP_xEMA2 = ExpAverage(BOP_xEMA1, BOP_TEMA_Length);
def BOP_xEMA3 = ExpAverage(BOP_xEMA2, BOP_TEMA_Length);
def BOP_nRes = 3 * BOP_xEMA1 - 3 * BOP_xEMA2 + BOP_xEMA3;
def BOP_SmootherBOP = BOP_nRes;
def BOP_s1 = BOP_SmoothBOP;
def BOP_s2 = BOP_SmootherBOP;
def BOP_s3 = BOP_SmootherBOP[2];
def BOP_Direction = if BarNumber() == 1 then 0
else if BOP_s2 < BOP_s3 and BOP_s2[1] > BOP_s3[1] then -1
else if BOP_s2 > BOP_s3 and BOP_s2[1] < BOP_s3[1] then 1
else BOP_Direction[1];
### Fibonacci SuperTrend
input FST_Length = 11;
input FST_Retrace = 23.6;
input FST_UseHighLow = yes;
def FST_h = if FST_UseHighLow then high else close;
def FST_l = if FST_UseHighLow then low else close;
def FST_minL = Lowest(FST_l, FST_Length);
def FST_maxH = Highest(FST_h, FST_Length);
def FST_hh = if FST_h > FST_maxH[1] then FST_h else FST_hh[1];
def FST_ll = if FST_l < FST_minL[1] then FST_l else FST_ll[1];
def FST_trend = if FST_h > FST_maxH[1] then 1 else if FST_l < FST_minL[1] then -1 else FST_trend[1];
def FST_Direction = if BarNumber() == 0 then 0
else if FST_trend != 1 then -1
else if FST_trend == 1 then 1
else FST_Direction[1];
### Strategy
def BullBear_Buy = if FST_Direction ==1 then FST_Direction == 1 else no;
plot signal1 = MF_SIGNAL and MACDBB_OVERALL_SIGNAL and RSM_Buy and HMA_SIGNAL and BOP_Direction and BullBear_Buy and !BullBear_Buy[1];