Created
July 7, 2024 01:21
-
-
Save hoangbits/f8174c4d9d51df52a7c1048adfcf18b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@version=5 | |
indicator("ICT RBRD by GHoang Le", overlay=true) | |
// Function to check if a candle is bearish | |
is_bearish(index) => close[index] < open[index] | |
// Function to check if a candle is bullish | |
is_bullish(index) => close[index] > open[index] | |
// Function to check if a candle has a bottom wick | |
has_bottom_wick(index) => low[index] < math.min(open[index], close[index]) | |
// Function to check if a candle has a top wick | |
has_top_wick(index) => high[index] > math.max(open[index], close[index]) | |
// Check for bearish RBRD pattern | |
bearish_rbrd = is_bearish(0) and is_bearish(1) and has_bottom_wick(1) and open[0] >= close[1] and close[0] <= low[1] | |
// Check for bullish RBRD pattern | |
bullish_rbrd = is_bullish(0) and is_bullish(1) and has_top_wick(1) and open[0] <= close[1] and close[0] >= high[1] | |
// Plot arrows for the patterns | |
plotshape(bearish_rbrd, title="Bearish RBRD", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small) | |
plotshape(bullish_rbrd, title="Bullish RBRD", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small) | |
// Draw rectangle boxes for wicks | |
if bullish_rbrd | |
box.new(bar_index[1], high[1], bar_index, math.max(open[1], close[1]), bgcolor=color.new(color.green, 80), border_color=color.green) | |
// label.new(bar_index, high, "Bullish", color=color.green, textcolor=color.white, style=label.style_label_down) | |
if bearish_rbrd | |
box.new(bar_index[1], low[1], bar_index, math.min(open[1], close[1]), bgcolor=color.new(color.red, 80), border_color=color.red) | |
// label.new(bar_index, low, "Bearish", color=color.red, textcolor=color.white, style=label.style_label_up) | |
// Debugging information | |
var table debugTable = table.new(position.top_right, 2, 2) | |
table.cell(debugTable, 0, 0, "Bullish Count") | |
table.cell(debugTable, 1, 0, "Bearish Count") | |
var int bullishCount = 0 | |
var int bearishCount = 0 | |
if bullish_rbrd | |
bullishCount += 1 | |
if bearish_rbrd | |
bearishCount += 1 | |
table.cell(debugTable, 0, 1, str.tostring(bullishCount)) | |
table.cell(debugTable, 1, 1, str.tostring(bearishCount)) | |
// Alert conditions | |
alertcondition(bearish_rbrd, title="Bearish RBRD Detected", message="Bearish RBRD pattern detected") | |
alertcondition(bullish_rbrd, title="Bullish RBRD Detected", message="Bullish RBRD pattern detected") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment