Tradinview Indicator - Ichimoku Price Action
//@version=5
indicator("DrDuit Detector Ultimate", overlay=true)
// Ichimoku Cloud Parameters
conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")
basePeriods = input.int(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length")
displacement = input.int(26, minval=1, title="Displacement")
// Three Black Crows Parameters
min_body_size = input.float(0.3, "Minimum Body Size (%)", step=0.1) // Minimum body size as a % of candle range
volume_confirmation = input.bool(false, "Volume Confirmation", tooltip="Enable this for higher volume in the third candle")
rsi_length = input.int(14, "RSI Length", minval=1) // RSI length
rsi_threshold = 50 // RSI threshold for strong signal
// Shooting Star Parameters
body_ratio = input.float(0.3, title="Max Body Size (%) for Shooting Star", tooltip="Maximum body size as a percentage of the entire candle range", step=0.1)
upper_shadow_ratio = input.float(2.0, title="Min Upper Shadow Ratio for Shooting Star", tooltip="Minimum ratio of upper shadow to body size")
// Hammer Parameters
hammer_body_ratio = input.float(0.3, title="Max Body Size (%) for Hammer", tooltip="Maximum body size as a percentage of the entire candle range", step=0.1)
lower_shadow_ratio = input.float(2.0, title="Min Lower Shadow Ratio for Hammer", tooltip="Minimum ratio of lower shadow to body size")
// Ichimoku Cloud Calculation
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
laggingSpan = close // Lagging Span is simply the closing price shifted back
// Plot Ichimoku Cloud Lines
p1 = plot(leadLine1, offset=displacement, color=#A5D6A7, title="Leading Span A")
p2 = plot(leadLine2, offset=displacement, color=#EF9A9A, title="Leading Span B")
fill(p1, p2, color=leadLine1 > leadLine2 ? color.new(color.green, 80) : color.new(color.red, 80), title="Cloud")
// Plot Lagging Span (Chikou Span)
plot(laggingSpan, offset=-displacement, color=#43A047, title="Lagging Span")
// Calculate RSI
rsi = ta.rsi(close, rsi_length)
// Three Black Crows Detection Function
is_bearish_candle(open, close, high, low) =>
body_size = math.abs(close - open)
candle_range = high - low
body_size >= candle_range * min_body_size and close < open
// Three Black Crows Logic
candle1 = is_bearish_candle(open[2], close[2], high[2], low[2])
candle2 = is_bearish_candle(open[1], close[1], high[1], low[1]) and open[1] < close[2] * 1.01
candle3 = is_bearish_candle(open, close, high, low) and open < close[1] * 1.01
// Volume Confirmation (Optional)
vol_condition = not volume_confirmation or (volume > volume[1] and volume[1] > volume[2])
// Check if Three Black Crows Pattern is Formed and if RSI is Above 50
three_black_crows = candle1 and candle2 and candle3 and vol_condition
strong_three_black_crows = three_black_crows and rsi > rsi_threshold
// Shooting Star Detection Function
is_shooting_star(open, high, low, close) =>
candle_range = high - low
body_size = math.abs(close - open)
upper_shadow = high - math.max(open, close)
lower_shadow = math.min(open, close) - low
// Criteria for Shooting Star
small_body = (body_size / candle_range) <= body_ratio
long_upper_shadow = upper_shadow >= (upper_shadow_ratio * body_size)
small_lower_shadow = lower_shadow < (body_size * 0.1)
small_body and long_upper_shadow and small_lower_shadow
// Detect Shooting Star
shooting_star = is_shooting_star(open, high, low, close)
// Check if next candle closes below the body of the Shooting Star for a Strong SS signal
strong_shooting_star = shooting_star[1] and close < math.min(open[1], close[1])
// Three White Soldiers Detection Function
is_bullish_candle(open, close, high, low) =>
body_size = math.abs(close - open)
candle_range = high - low
body_size >= candle_range * min_body_size and close > open
// Three White Soldiers Logic
bull_candle1 = is_bullish_candle(open[2], close[2], high[2], low[2])
bull_candle2 = is_bullish_candle(open[1], close[1], high[1], low[1]) and open[1] > close[2] * 0.99
bull_candle3 = is_bullish_candle(open, close, high, low) and open > close[1] * 0.99
three_white_soldiers = bull_candle1 and bull_candle2 and bull_candle3
// Hammer Detection Function
is_hammer(open, high, low, close) =>
candle_range = high - low
body_size = math.abs(close - open)
lower_shadow = math.min(open, close) - low
upper_shadow = high - math.max(open, close)
// Criteria for Hammer
small_body = (body_size / candle_range) <= hammer_body_ratio
long_lower_shadow = lower_shadow >= (lower_shadow_ratio * body_size)
small_upper_shadow = upper_shadow < (body_size * 0.1)
small_body and long_lower_shadow and small_upper_shadow
// Detect Hammer
hammer = is_hammer(open, high, low, close)
// Check if the next candle closes above the body of the Hammer for a Strong Hammer signal
strong_hammer = hammer[1] and close > math.max(open[1], close[1])
// Bearish Engulfing Detection
bearish_engulfing = close[1] > open[1] and open > close[1] and close < open[1]
// Bullish Engulfing Detection
bullish_engulfing = close[1] < open[1] and close > open[1] and open < close[1]
// Belt Hold Detection with a tolerance for small shadows
tolerance = 0.02 // Allows up to 2% shadow relative to the candle range
// Updated Bullish Belt Hold Detection
bullish_belt_hold = (close > open) and (open == low) and (high > close)
// Updated Bearish Belt Hold Detection
bearish_belt_hold = (close < open) and (open == high) and (low < close)
// Marubozu Detection
bullish_marubozu = close > open and (open - low) <= (high - low) * tolerance and (high - close) <= (high - low) * tolerance
bearish_marubozu = close < open and (high - open) <= (high - low) * tolerance and (close - low) <= (high - low) * tolerance
// Piercing Line Detection (Bullish Reversal)
piercing_line = close[1] < open[1] and open < low[1] and close > open and close > (open[1] + close[1]) / 2
// Dark Cloud Cover Detection (Bearish Reversal)
dark_cloud_cover = close[1] > open[1] and open > high[1] and close < open and close < (open[1] + close[1]) / 2
// Doji Detection Function
is_doji(open, close, high, low) =>
body_size = math.abs(close - open)
candle_range = high - low
body_size <= candle_range * 0.1 // Body size is 10% or less of the range, indicating a Doji
// Bullish Doji Star Detection
bullish_doji_star = close[1] < open[1] and is_doji(open, close, high, low) and open < low[1]
// Bearish Doji Star Detection
bearish_doji_star = close[1] > open[1] and is_doji(open, close, high, low) and open > high[1]
// Gravestone Doji Detection
is_gravestone_doji(open, close, high, low) =>
body_size = math.abs(close - open)
candle_range = high - low
upper_shadow = high - math.max(open, close)
lower_shadow = math.min(open, close) - low
// Criteria for Gravestone Doji
small_body = body_size <= candle_range * 0.1 // Body size is 10% or less of the total range
long_upper_shadow = upper_shadow > candle_range * 0.6 // Upper shadow is more than 60% of the range
very_small_lower_shadow = lower_shadow <= candle_range * 0.05 // Lower shadow is 5% or less of the range
small_body and long_upper_shadow and very_small_lower_shadow
// Gravestone Doji Signal
gravestone_doji = is_gravestone_doji(open, close, high, low)
// Function to detect Bearish Engulfing with exclusion for Bearish Belt Hold
// Function to detect Bearish Engulfing with exclusion for Bearish Belt Hold
is_bearish_engulfing(open, close, high, open_prev, close_prev) =>
// Memastikan candle sebelumnya bullish
bullish_prev = close_prev > open_prev
// Memastikan candle saat ini bearish dan tubuhnya menutupi candle sebelumnya
bearish_current = close < open and open >= close_prev and close <= open_prev
// Pastikan ini bukan Bearish Belt Hold (yaitu, candle saat ini tidak dibuka di titik tertinggi atau mendekati tertinggi)
not_belt_hold = (high - open) / (high - low) > 0.05 // Toleransi 5% untuk memastikan tidak dianggap Belt Hold
// Kondisi Bearish Engulfing terpenuhi jika candle saat ini bearish dan mengengulf candle sebelumnya serta bukan Belt Hold
bullish_prev and bearish_current and not_belt_hold
// Deteksi Bearish Engulfing
bearish_engulfing2 = is_bearish_engulfing(open, close, high, open[1], close[1])
// Function to detect Bullish Engulfing with additional flexibility
is_bullish_engulfing(open, close, open_prev, close_prev, high_prev, low_prev) =>
// Memastikan candle sebelumnya bearish
bearish_prev = close_prev < open_prev
// Memastikan candle saat ini bullish dan menutupi tubuh candle sebelumnya, dengan toleransi tambahan
bullish_current = close > open and open <= close_prev and close >= open_prev and close > close_prev
// Kondisi Bullish Engulfing terpenuhi jika candle saat ini bullish dan mengengulf candle sebelumnya
bearish_prev and bullish_current
// Deteksi Bullish Engulfing
bullish_engulfing2 = is_bullish_engulfing(open, close, open[1], close[1], high[1], low[1])
// Function to check if a candle is bullish
is_bullish(open, close) =>
close > open
// Function to check if a candle is bearish
is_bearish(open, close) =>
close < open
// Function to check if a candle is small (doji or spinning top)
is_small_candle(open, close, high, low) =>
body_size = math.abs(close - open)
candle_range = high - low
// Body size is less than 30% of the candle range, indicating a small candle
body_size <= candle_range * 0.3
// Function to detect Evening Star pattern
is_evening_star(open1, close1, open2, close2, open3, close3, high2, low2, high3, low3) =>
// Check the first candle (bullish with a strong body)
is_bullish(open1, close1) and (close1 - open1) > (high2 - low2) * 0.5 and is_small_candle(open2, close2, high2, low2) and is_bearish(open3, close3) and (close3 < (open1 + close1) / 2)
// Detect Evening Star pattern on the third candle
evening_star = is_evening_star(open[2], close[2], open[1], close[1], open, close, high[1], low[1], high, low)
// Function to detect Morning Star pattern
is_morning_star(open1, close1, open2, close2, open3, close3, high2, low2) =>
// Check the first candle (bearish with a strong body)
is_bearish(open1, close1) and (open1 - close1) > (high2 - low2) * 0.5 and is_small_candle(open2, close2, high2, low2) and is_bullish(open3, close3) and (close3 > (open1 + close1) / 2)
// Detect Morning Star pattern on the third candle
morning_star = is_morning_star(open[2], close[2], open[1], close[1], open, close, high[1], low[1])
// Inisialisasi tabel di pojok kanan atas dengan 3 kolom dan 16 baris
var table patternTable = table.new(position = position.top_right, columns = 3, rows = 28, frame_color = color.white, frame_width = 2, border_color = color.white)
// Header Tabel
table.cell(patternTable, 0, 0, "Tipe", text_color=color.black, bgcolor=color.yellow)
table.cell(patternTable, 1, 0, "Acc", text_color=color.black, bgcolor=color.yellow)
table.cell(patternTable, 2, 0, "Full Name", text_color=color.black, bgcolor=color.yellow)
// Data Pola Bullish
table.cell(patternTable, 0, 1, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 1, "Hmr", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 1, "Hammer", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 0, 2, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 2, "IHmr", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 2, "Inverse Hammer", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 0, 3, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 3, "BuE", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 3, "Bulish Engulfing", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 0, 4, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 4, "PL", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 4, "Piercing Line", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 0, 5, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 5, "MS", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 5, "Morning Star", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 0, 6, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 6, "TWS", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 6, "Three White Soldier", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 0, 7, "Bulish", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 1, 7, "BuBH", text_color=color.black, bgcolor=color.green)
table.cell(patternTable, 2, 7, "Bulish Belt Hold", text_color=color.black, bgcolor=color.green)
// Data Pola Bearish
table.cell(patternTable, 0, 8, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 8, "HM", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 8, "Hanging Man", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 0, 9, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 9, "SS", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 9, "Shooting Star", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 0, 10, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 10, "BeE", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 10, "Bearish Engulfing", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 0, 11, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 11, "ES", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 11, "Evening Star", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 0, 12, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 12, "TBC", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 12, "Three Black Crows", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 0, 13, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 13, "DCC", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 13, "Dark Cloud Cover", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 0, 14, "Bearish", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 1, 14, "BeBH", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
table.cell(patternTable, 2, 14, "Bearish Belt Hold", text_color=color.black, bgcolor=color.rgb(223, 121, 241))
// Data Pola Lanjutan
table.cell(patternTable, 0, 15, "Continues", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 1, 15, "DJ", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 2, 15, "Doji", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 0, 16, "Continues", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 1, 16, "SpT", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 2, 16, "Spinning Top", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 0, 17, "Continues", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 1, 17, "FTM", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 2, 17, "Falling Three Methods", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 0, 18, "Continues", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 1, 18, "RTM", text_color=color.black, bgcolor=#77baf1)
table.cell(patternTable, 2, 18, "Rising Three Methods", text_color=color.black, bgcolor=#77baf1)
// Data Pola Reversal Bearish dan Bullish
table.cell(patternTable, 0, 19, "Reversal Bearish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 19, "HNS", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 19, "Hand And Shoulder", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 20, "Reversal Bearish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 20, "DTP", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 20, "Double Top", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 21, "Reversal Bearish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 21, "ARW", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 21, "A Rising Wedge", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 22, "Reversal Bearish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 22, "AFW", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 22, "A Falling Wedge", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 23, "Reversal Bearish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 23, "AT", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 23, "Ascending Triangle", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 24, "Reversal Bullish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 24, "DBT", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 24, "Double Bottom", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 25, "Reversal Bullish", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 25, "CnH", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 25, "Cup and Handle", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 26, "Reversal Bull", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 26, "PNT", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 26, "Pennant", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 0, 27, "Continues", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 1, 27, "SMT", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
table.cell(patternTable, 2, 27, "Symmetrical Triangle", text_color=color.black, bgcolor=color.rgb(245, 136, 167))
// Plot Three Black Crows Signals
bgcolor(three_black_crows ? color.new(color.red, 90) : na)
plotshape(series=strong_three_black_crows, location=location.belowbar, color=color.new(color.red, 80), style=shape.labeldown, text="Strong TBC", textcolor=#ffffff52)
plotshape(series=three_black_crows and not strong_three_black_crows, location=location.belowbar, color=color.new(color.red, 80), style=shape.labeldown, text="TBC", textcolor=#ffffff52)
// Plot Shooting Star Signals
plotshape(series=shooting_star, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="SS", textcolor=#ffffff52)
plotshape(series=strong_shooting_star, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="Strong SS", textcolor=#ffffff52)
// Plot Three White Soldiers Signal
plotshape(series=three_white_soldiers, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="TWS", textcolor=#ffffff52)
// Plot Hammer Signals
plotshape(series=hammer, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="Hmr", textcolor=#ffffff52)
plotshape(series=strong_hammer, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="Shmr", textcolor=#ffffff52)
// Plot Bearish Engulfing Signal
plotshape(series=bearish_engulfing, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="BeE", textcolor=#ffffff52)
// Plot Bullish Engulfing Signal
plotshape(series=bullish_engulfing, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="BuE", textcolor=#ffffff52)
// Plot Belt Hold Signals
plotshape(series=bullish_belt_hold, location=location.belowbar,color=color.new(color.green, 80), style=shape.labelup, text="BuBH", textcolor=#ffffff52)
plotshape(series=bearish_belt_hold, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="BeBH", textcolor=#ffffff52)
// Plot Marubozu Signals
plotshape(series=bullish_marubozu, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="Bu Marubozu", textcolor=#ffffff52)
plotshape(series=bearish_marubozu, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="Bear Morubuzo", textcolor=#ffffff52)
// Plot Piercing Line Signal
plotshape(series=piercing_line, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="PL", textcolor=#ffffff52)
// Plot Dark Cloud Cover Signal
plotshape(series=dark_cloud_cover, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="DCC", textcolor=#ffffff52)
// Plot Doji Star Signals
plotshape(series=bullish_doji_star, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="BuDS", textcolor=#ffffff52)
plotshape(series=bearish_doji_star, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="BeDS", textcolor=#ffffff52)
// Plot Gravestone Doji Signal
plotshape(series=gravestone_doji, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="GDo", textcolor=#ffffff52)
// Plot Bearish Engulfing Signal
plotshape(series=bearish_engulfing2, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="BeE 2", textcolor=#ffffff52)
// Plot Bullish Engulfing Signal
plotshape(series=bullish_engulfing2, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="BuE 2", textcolor=#ffffff52)
// Plot signal on the third candle only if Evening Star pattern is detected
// Plot signal on the third candle if Evening Star pattern is detected
plotshape(series=evening_star, location=location.abovebar, color=color.new(color.red, 80), style=shape.labeldown, text="ES", textcolor=#ffffff52)
bgcolor(evening_star ? color.new(color.red, 90) : na)
// Plot signal on the third candle if Morning Star pattern is detected
plotshape(series=morning_star, location=location.belowbar, color=color.new(color.green, 80), style=shape.labelup, text="MS", textcolor=#ffffff52)
bgcolor(morning_star ? color.new(color.green, 90) : na)