OPEN-SOURCE SCRIPT
Smart Entry System

//version=5
indicator("Smart Entry System", overlay=true)
// ── Inputs ──
len = input.int(20, title="Structure Lookback")
// ── Market Structure Shift ──
mssBuy = low < ta.lowest(low, len) and high > ta.highest(high, len)
mssSell = high > ta.highest(high, len) and low < ta.lowest(low, len)
// ── Fair Value Gap ──
fvgUp = low[2] > high and low[1] > high
fvgDown = high[2] < low and high[1] < low
// ── Breaker Block ──
breakerBuy = close[2] > open[2] and close[1] < open[1] and close > open
breakerSell = close[2] < open[2] and close[1] > open[1] and close < open
// ── Inversion Point ──
inversionBuy = close > high[1] and close[1] < high[2]
inversionSell = close < low[1] and close[1] > low[2]
// ── Fibonacci Levels ──
var float fibHigh = na
var float fibLow = na
if mssBuy
fibLow := low
fibHigh := ta.highest(high, len)
else if mssSell
fibHigh := high
fibLow := ta.lowest(low, len)
// Avoid plotting if values are not ready
validFib = not na(fibHigh) and not na(fibLow)
fib38 = validFib ? fibHigh - (fibHigh - fibLow) * 0.382 : na
fib61 = validFib ? fibHigh - (fibHigh - fibLow) * 0.618 : na
plot(fib38, title="Fib 38.2%", color=color.gray, linewidth=1)
plot(fib61, title="Fib 61.8%", color=color.gray, linewidth=1)
// ── Entry Conditions ──
buyEntry = mssBuy and fvgUp and breakerBuy and inversionBuy and close < fib61
sellEntry = mssSell and fvgDown and breakerSell and inversionSell and close > fib38
// ── Entry Plot ──
plotshape(buyEntry, title="Buy Entry", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellEntry, title="Sell Entry", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
indicator("Smart Entry System", overlay=true)
// ── Inputs ──
len = input.int(20, title="Structure Lookback")
// ── Market Structure Shift ──
mssBuy = low < ta.lowest(low, len) and high > ta.highest(high, len)
mssSell = high > ta.highest(high, len) and low < ta.lowest(low, len)
// ── Fair Value Gap ──
fvgUp = low[2] > high and low[1] > high
fvgDown = high[2] < low and high[1] < low
// ── Breaker Block ──
breakerBuy = close[2] > open[2] and close[1] < open[1] and close > open
breakerSell = close[2] < open[2] and close[1] > open[1] and close < open
// ── Inversion Point ──
inversionBuy = close > high[1] and close[1] < high[2]
inversionSell = close < low[1] and close[1] > low[2]
// ── Fibonacci Levels ──
var float fibHigh = na
var float fibLow = na
if mssBuy
fibLow := low
fibHigh := ta.highest(high, len)
else if mssSell
fibHigh := high
fibLow := ta.lowest(low, len)
// Avoid plotting if values are not ready
validFib = not na(fibHigh) and not na(fibLow)
fib38 = validFib ? fibHigh - (fibHigh - fibLow) * 0.382 : na
fib61 = validFib ? fibHigh - (fibHigh - fibLow) * 0.618 : na
plot(fib38, title="Fib 38.2%", color=color.gray, linewidth=1)
plot(fib61, title="Fib 61.8%", color=color.gray, linewidth=1)
// ── Entry Conditions ──
buyEntry = mssBuy and fvgUp and breakerBuy and inversionBuy and close < fib61
sellEntry = mssSell and fvgDown and breakerSell and inversionSell and close > fib38
// ── Entry Plot ──
plotshape(buyEntry, title="Buy Entry", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellEntry, title="Sell Entry", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.