Aaa
2025-02-12
Category: None

//@version=5
indicator("BOS and CHoCH Indicator", overlay=true)

// تنظیمات اولیه
length = input.int(14, title="Length")
threshold = input.float(1.5, title="Threshold")

// محاسبه highs و lows
highs = ta.highest(high, length)
lows = ta.lowest(low, length)

// شناسایی BOS (Break of Structure)
bos_up = ta.crossover(high, highs )
bos_down = ta.crossunder(low, lows )

// شناسایی CHoCH (Change of Character)
choch_up = ta.crossover(high, highs ) and ta.crossover(close, high)
choch_down = ta.crossunder(low, lows ) and ta.crossunder(close, low)

// رسم علائم روی چارت
plotshape(series=bos_up, title="BOS Up", location=location.belowbar, color=color.green, style=shape.labelup, text="BOS")
plotshape(series=bos_down, title="BOS Down", location=location.abovebar, color=color.red, style=shape.labeldown, text="BOS")
plotshape(series=choch_up, title="CHoCH Up", location=location.belowbar, color=color.blue, style=shape.labelup, text="CHoCH")
plotshape(series=choch_down, title="CHoCH Down", location=location.abovebar, color=color.orange, style=shape.labeldown, text="CHoCH")

// نمایش خطوط برای BOS و CHoCH
line.new(x1