|
| 1 | +//@version=5 |
| 2 | +indicator("SMC Liquidity + BOS Strategy", overlay=true, timeframe="5", timeframe_gaps=true) |
| 3 | + |
| 4 | +// βββ Input Parameters βββ |
| 5 | +trend_tf = input.timeframe("60", "Trend Timeframe (1H)") |
| 6 | +liquidity_tf = input.timeframe("30", "Liquidity Timeframe (30m)") |
| 7 | +RR = input.float(2.0, "Risk-Reward (TP = RR Γ SL)") |
| 8 | +lookback = input.int(12, "Lookback bars for BOS", minval=3) |
| 9 | +show_labels = input.bool(true, "Show Entry/Exit Labels") |
| 10 | + |
| 11 | +// βββ Higher timeframe data βββ |
| 12 | +[high1h, low1h, close1h] = request.security(syminfo.tickerid, trend_tf, [high, low, close]) |
| 13 | +[high30, low30] = request.security(syminfo.tickerid, liquidity_tf, [high, low]) |
| 14 | + |
| 15 | +// βββ Detect simple trend (HH/HL) βββ |
| 16 | +var float prev_high1h = na |
| 17 | +var float prev_low1h = na |
| 18 | +var int trend = 0 // 1 = uptrend, -1 = downtrend, 0 = neutral |
| 19 | + |
| 20 | +if barstate.isnew |
| 21 | + if not na(prev_high1h) |
| 22 | + if high1h > prev_high1h and low1h > prev_low1h |
| 23 | + trend := 1 |
| 24 | + else if high1h < prev_high1h and low1h < prev_low1h |
| 25 | + trend := -1 |
| 26 | + else |
| 27 | + trend := 0 |
| 28 | + prev_high1h := high1h |
| 29 | + prev_low1h := low1h |
| 30 | + |
| 31 | +// βββ Liquidity sweep check βββ |
| 32 | +liq_sweep_high = high > high30[1] and close < high |
| 33 | +liq_sweep_low = low < low30[1] and close > low |
| 34 | + |
| 35 | +// βββ Break of Structure (BOS) on current timeframe βββ |
| 36 | +bos_short = close < ta.lowest(low, lookback)[1] |
| 37 | +bos_long = close > ta.highest(high, lookback)[1] |
| 38 | + |
| 39 | +// βββ Entry Conditions βββ |
| 40 | +short_entry = (trend <= 0) and liq_sweep_high and bos_short |
| 41 | +long_entry = (trend >= 0) and liq_sweep_low and bos_long |
| 42 | + |
| 43 | +// βββ Plot Buy/Sell Arrows βββ |
| 44 | +plotshape(short_entry, title="Sell Signal", style=shape.triangledown, color=color.red, size=size.large, location=location.abovebar, text="SELL") |
| 45 | +plotshape(long_entry, title="Buy Signal", style=shape.triangleup, color=color.lime, size=size.large, location |
0 commit comments