//@version=5 strategy("SMC Engine - 5 Rule Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // ========================================== // INPUTS & CONFIGURATION // ========================================== var string G_SESS = "Session Settings (New York Time)" asiaSession = input.session("2000-0200", title="Asia Session", group=G_SESS) londonSession = input.session("0200-0500", title="London Execution Window", group=G_SESS) nySession = input.session("0700-1000", title="New York Execution Window", group=G_SESS) timezoneInput = input.string("America/New_York", title="Session Timezone", group=G_SESS) var string G_SMC = "SMC Parameters" rrRatio = input.float(6.23, title="Risk-to-Reward Ratio (Average is 6.23)", minval=0.1, group=G_SMC) fvgThreshold = input.float(0.0, title="Minimum FVG Size in Points", group=G_SMC, tooltip="Filters out microscopic FVGs") useChoch = input.bool(true, title="Require 1m/LTF Reversal Shift (CHoCH)", group=G_SMC) // ========================================== // SESSION TRACKING // ========================================== inAsia = not na(time(timeframe.period, asiaSession, timezoneInput)) inLondon = not na(time(timeframe.period, londonSession, timezoneInput)) inNY = not na(time(timeframe.period, nySession, timezoneInput)) inTradeWindow = inLondon or inNY var float asiaHigh = na var float asiaLow = na var bool asiaRangeSet = false // Detect new Asia Session and reset high/low tracking newAsia = inAsia and not inAsia[1] if newAsia asiaHigh := high asiaLow := low asiaRangeSet := true else if inAsia asiaHigh := math.max(high, nz(asiaHigh, high)) asiaLow := math.min(low, nz(asiaLow, low)) // Visualizing Asia Range plot(asiaRangeSet and not inAsia ? asiaHigh : na, title="Asia Session High", color=color.new(color.red, 30), style=plot.style_linebreak, linewidth=2) plot(asiaRangeSet and not inAsia ? asiaLow : na, title="Asia Session Low", color=color.new(color.blue, 30), style=plot.style_linebreak, linewidth=2) // ========================================== // LIQUIDATION / SWEEP DETECTION // ========================================== var bool highSwept = false var bool lowSwept = false // Reset sweep status daily when Asia starts if newAsia highSwept := false lowSwept := false // Detect sweeps during execution windows if inTradeWindow and asiaRangeSet if high > asiaHigh highSwept := true if low < asiaLow lowSwept := true // ========================================== // REVERSAL CONFIRMATION & FVGS (ENTRY TRIGGERS) // ========================================== // Bearish CHoCH: Close below previous swing/local low after high sweep bearishCHoCH = highSwept and ta.falling(close, 1) and close < ta.valuewhen(highSwept and not highSwept[1], low, 0) // Bullish CHoCH: Close above previous swing/local high after low sweep bullishCHoCH = lowSwept and ta.rising(close, 1) and close > ta.valuewhen(lowSwept and not lowSwept[1], high, 0) // Fair Value Gap Detection // Bearish FVG: Low of candle 3 is greater than High of candle 1 bearishFVG = (low[2] > high) and (low[2] - high > fvgThreshold) // Bullish FVG: High of candle 3 is less than Low of candle 1 bullishFVG = (high[2] < low) and (low - high[2] > fvgThreshold) // ========================================== // STRATEGY EXECUTION // ========================================== var float entryPrice = na var float stopLossPrice = na var float takeProfitPrice = na // Trade state trackers to avoid multiple entries within the same session window var int lastTradeBar = 0 if inTradeWindow and (bar_index > lastTradeBar) and (strategy.position_size == 0) // Bearish Setup: High swept, validated by Bearish FVG and CHoCH if highSwept and bearishFVG and (not useChoch or bearishCHoCH) entryPrice := close stopLossPrice := math.max(high[1], high[2]) // Keep stop loss tight above the sweep structure float risk = stopLossPrice - entryPrice if risk > 0 takeProfitPrice := entryPrice - (risk * rrRatio) strategy.entry("SMC-Short", strategy.short) strategy.exit("Short-Exit", "SMC-Short", stop=stopLossPrice, limit=takeProfitPrice) lastTradeBar := bar_index highSwept := false // Reset sweep trigger after execution // Bullish Setup: Low swept, validated by Bullish FVG and CHoCH if lowSwept and bullishFVG and (not useChoch or bullishCHoCH) entryPrice := close stopLossPrice := math.min(low[1], low[2]) // Keep stop loss tight below the sweep structure float risk = entryPrice - stopLossPrice if risk > 0 takeProfitPrice := entryPrice + (risk * rrRatio) strategy.entry("SMC-Long", strategy.long) strategy.exit("Long-Exit", "SMC-Long", stop=stopLossPrice, limit=takeProfitPrice) lastTradeBar := bar_index lowSwept := false // Reset sweep trigger after execution // Visualizing Sweeps and Entries plotshape(highSwept and not highSwept[1], title="Buy-Side Liquidity Swept", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) plotshape(lowSwept and not lowSwept[1], title="Sell-Side Liquidity Swept", style=shape.triangleup, location=location.belowbar, color=color.blue, size=size.small)