# 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.
# Join us at [Link]
#
#
# v1.2 - Assembled by Chuck Edwards
# v2.0 - Barbaros - Scanner Update, removed Market Forecast, HULL Concavity and
Squeeze due to ToS limitation
# v2.1 - Barbaros - Separated out BullBear options for combinations
# v2.2 - Barbaros - Removed BOP for efficiency
### MACDBB
input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 15;
input MACDBB_Length = 25;
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([Link],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;