//@version=5 indicator("Group", overlay = true) // { ==== BB ==== lengthBB =…
- User
//@version=5 indicator("Group", overlay = true)
// { ==== BB ==== length_BB = input.int(20, minval=1, title="BB Length") src_BB = input(close, title="Source") mult_BB = input.float(2.0, minval=0.001, maxval=50, title="StdDev Multiplier") basis = ta.ema(src_BB, length_BB) dev = mult_BB * ta.stdev(src_BB, length_BB) upper = basis + dev lower = basis - dev plot(basis, "Basis", color=color.blue) p1 = plot(upper, "Upper", color=color.red) p2 = plot(lower, "Lower", color=color.green)
// Long Condition BB long_con1_bb = (low <= lower) and (open > lower and open < basis) and (close > lower and close < basis) and (high < basis) number_candle_long_con1_bb = ta.barssince(long_con1_bb) long_con2_bb = number_candle_long_con1_bb > 0 and number_candle_long_con1_bb <= 6 and (close > lower and open > lower) and close > high[number_candle_long_con1_bb] // plotshape(series = long_con2_bb, size = size.large, location = location.belowbar, style = shape.triangleup, color = color.green)
// Short Condition BB short_con1_bb = (high >= upper) and (open < upper and open > basis) and (close < upper and close > basis) and (low > basis) number_candle_short_con1_bb = ta.barssince(short_con1_bb) short_con2_bb = number_candle_short_con1_bb > 0 and number_candle_short_con1_bb <= 6 and (close < upper and open < upper) and close < low[number_candle_short_con1_bb] // plotshape(series = short_con2_bb, size = size.large, location = location.abovebar, style = shape.triangledown, color = color.red) // }
// { === Candle Pattern Identification === // Parameters for pin bar pinBarBodyRatio = 0.5 pinBarTailRatio = 1.3
// Calculate lengths bodyLength = math.abs(open - close) upperShadow = high - math.max(open, close) lowerShadow = math.min(open, close) - low
// Identify Bullish Pin Bar isBullishPinBar = (lowerShadow > bodyLength * pinBarTailRatio) and (bodyLength < (high - low) * pinBarBodyRatio) and (upperShadow < bodyLength) con_long_pinbar_bb = isBullishPinBar and long_con1_bb // plotshape(series = con_long_pinbar_bb, size = size.large, location = location.belowbar, style = shape.triangleup, color = color.green)
// Identify Bearish Pin Bar isBearishPinBar = (upperShadow > bodyLength * pinBarTailRatio) and (bodyLength < (high - low) * pinBarBodyRatio) and (lowerShadow < bodyLength) con_short_pinbar_bb = isBearishPinBar and short_con1_bb // plotshape(series = con_short_pinbar_bb, size = size.large, location = location.abovebar, style = shape.triangledown, color = color.red)
// Identify and plot Bullish and Bearish Engulfing Patterns isBullishEngulfing = (close[1] < open[1]) and (close > open) and (close >= open[1]) and (open <= close[1]) plotshape(series=isBullishEngulfing, location=location.belowbar, color=color.green, style=shape.triangleup, text="Bull Engulf", size=size.small)
isBearishEngulfing = (close[1] > open[1]) and (close < open) and (open >= close[1]) and (close <= open[1]) plotshape(series=isBearishEngulfing, location=location.abovebar, color=color.red, style=shape.triangledown, text="Bear Engulf", size=size.small) // }
- Assistant
- User
- Assistant
- User
- Assistant