//@version=6
indicator("Krshn – Sniper Scalping System v2", overlay=true, max_boxes_count=20,
max_labels_count=50)
// === Input Parameters ===
lookbackHigh = input.int(20, "Swing High Lookback")
lookbackLow = input.int(20, "Swing Low Lookback")
zoneWidth = input.int(3, "Zone Width (ticks)")
tp1_ratio = input.float(1.5, "TP1 Risk:Reward")
tp2_ratio = input.float(2.5, "TP2 Risk:Reward")
tp3_ratio = input.float(3.5, "TP3 Risk:Reward")
fractalsPeriod = input.int(25, "Fractals Period", minval=2)
// === Supply/Demand Zones ===
var float supplyHigh = na
var float supplyLow = na
var float demandLow = na
var float demandHigh = na
if ta.highestbars(high, lookbackHigh) == 0
supplyHigh := high
supplyLow := high - zoneWidth * syminfo.mintick
box.new(left=bar_index-lookbackHigh, top=supplyHigh, right=bar_index,
bottom=supplyLow, bgcolor=color.new(color.red, 85), border_color=color.red)
if ta.lowestbars(low, lookbackLow) == 0
demandLow := low
demandHigh := low + zoneWidth * syminfo.mintick
box.new(left=bar_index-lookbackLow, top=demandHigh, right=bar_index,
bottom=demandLow, bgcolor=color.new(color.green, 85), border_color=color.green)
// === Candlestick Pattern Detection ===
bullishEngulfing = close[1] < open[1] and close > open and close > open[1] and open
<= close[1]
bearishEngulfing = close[1] > open[1] and close < open and close < open[1] and open
>= close[1]
invertedHammer = close > open and (high - close) > 2 * (close - open) and (open -
low) < (close - open)
avgRange = ta.sma(high - low, 10)
bigBar = (high - low) > 1.5 * avgRange
if bullishEngulfing
label.new(bar_index, low, "Bull Engulf", style=label.style_label_up,
color=color.green)
if bearishEngulfing
label.new(bar_index, high, "Bear Engulf", style=label.style_label_down,
color=color.red)
if invertedHammer
label.new(bar_index, high, "Inv Hammer", style=label.style_label_down,
color=color.blue)
if bigBar
label.new(bar_index, close, "Big Bar", color=color.orange)
// === Mirror Market Concept (MMC) ===
mirrorPrice = high + low - close
plot(mirrorPrice, color=color.purple, linewidth=1, title="Mirror Price")
crossZone = ta.crossover(close, mirrorPrice) or ta.crossunder(close, mirrorPrice)
if crossZone
line.new(bar_index-1, close[1], bar_index, close, color=color.fuchsia, width=2,
style=line.style_dotted)
// === Williams Fractals Logic ===
upFractal = ta.pivothigh(high, fractalsPeriod, fractalsPeriod)
downFractal = ta.pivotlow(low, fractalsPeriod, fractalsPeriod)
plotshape(downFractal, style=shape.triangledown, location=location.belowbar,
offset=-fractalsPeriod, color=#F44336, size = size.small)
plotshape(upFractal, style=shape.triangleup, location=location.abovebar, offset=-
fractalsPeriod, color=#009688, size = size.small)
// === Entry Logic ===
entryLong = bullishEngulfing and close >= demandLow and close <= demandHigh
entryShort = bearishEngulfing and close <= supplyHigh and close >= supplyLow
alertcondition(entryLong, title="Buy Signal", message="Bullish entry in demand/MMC
zone")
alertcondition(entryShort, title="Sell Signal", message="Bearish entry in
supply/MMC zone")
// === Trade Management ===
var bool inTrade = false
var float entryPrice = na
var float stopLoss = na
var float tp1 = na
var float tp2 = na
var float tp3 = na
if entryLong and not inTrade
inTrade := true
entryPrice := close
stopLoss := demandLow
tp1 := entryPrice + (entryPrice - stopLoss) * tp1_ratio
tp2 := entryPrice + (entryPrice - stopLoss) * tp2_ratio
tp3 := entryPrice + (entryPrice - stopLoss) * tp3_ratio
label.new(bar_index, entryPrice + 2 * syminfo.mintick, "Entry",
color=color.green)
line.new(bar_index, tp1, bar_index+5, tp1, color=color.green)
line.new(bar_index, tp2, bar_index+5, tp2, color=color.green)
line.new(bar_index, tp3, bar_index+5, tp3, color=color.green)
line.new(bar_index, stopLoss, bar_index+5, stopLoss, color=color.red, width=2)
label.new(bar_index, tp1, "TP1", color=color.green)
label.new(bar_index, tp2, "TP2", color=color.green)
label.new(bar_index, tp3, "TP3", color=color.green)
label.new(bar_index, stopLoss, "SL", color=color.red)
if inTrade and close >= tp1
stopLoss := entryPrice
label.new(bar_index, stopLoss, "SL to BE", color=color.aqua)
if inTrade
label.new(bar_index, entryPrice + 3 * syminfo.mintick, "Manage trade: Consider
partial TP at TP1", color=color.yellow)
riskReward = (tp1 - entryPrice) / (entryPrice - stopLoss)
if not na(entryPrice)
label.new(bar_index, entryPrice - 2 * syminfo.mintick, "R:R: " +
str.tostring(riskReward, format.percent), color=color.yellow)
plotshape(entryLong, title="Long Entry", location=location.belowbar,
style=shape.triangleup, color=color.lime, size=size.small)
plotshape(entryShort, title="Short Entry", location=location.abovebar,
style=shape.triangledown, color=color.red, size=size.small)