SMC Long + Short Entries & Exits — Strategy by artandinktattoogallery
By version
Performance Metrics
- Author: version
- Symbol: AMEX:SPY
- Timeframe: 5 minutes
- Net P&L: +28.47 USD (+0.28%)
- Win Rate: 68.8%
- Profit Factor: 5.044
- Max Drawdown: 6.47 USD (0.06%)
- Total Trades: 16
Description
//version=5strategy("SMC Long + Short Entries & Exits", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, pyramiding=0)// InputsemaLen = input.int(20, "EMA")swingLen = input.int(3, "Liquidity Swing Length")bosLen = input.int(10, "BOS Lookback")atrLen = input.int(14, "ATR Length")stopATR = input.float(0.6, "Stop ATR Multiplier")tp1RR = input.float(0.8, "TP1 RR")tp2RR = input.float(1.4, "TP2 RR")tp3RR = input.float(2.0, "TP3 RR")useBE = input.bool(true, "Move Stop To Breakeven After TP1")cooldown = input.int(8, "Cooldown Bars")// Coreema = ta.ema(close, emaLen)atr = ta.atr(atrLen)plot(ema, "EMA", color=color.fuchsia, linewidth=2)// Swingsph = ta.pivothigh(high, swingLen, swingLen)pl = ta.pivotlow(low, swingLen, swingLen)var float lastHigh = navar float lastLow = naif not na(ph) lastHigh := phif not na(pl) lastLow := pl// Liquidity sweepsbullSweep = not na(lastLow) and low lastLow and close > openbearSweep = not na(lastHigh) and high > lastHigh and close ta.highest(high, bosLen)[1]bearBOS = close atr * 0.25// Trend filterbullTrend = close > emabearTrend = close cooldown// Entry signalslongEntry = bullSweep and bullBOS and strongCandle and bullTrend and canTrade and strategy.position_size == 0shortEntry = bearSweep and bearBOS and strongCandle and bearTrend and canTrade and strategy.position_size == 0// Stored trade datavar float longSL = navar float shortSL = navar float longRisk = navar float shortRisk = na// Entriesif longEntry strategy.entry("LONG", strategy.long) longSL := low - atr * stopATR longRisk := close - longSL lastTradeBar := bar_indexif shortEntry strategy.entry("SHORT", strategy.short) shortSL := high + atr * stopATR shortRisk := shortSL - close lastTradeBar := bar_index// Position infoentryPrice = strategy.position_avg_pricelongTP1 = entryPrice + longRisk * tp1RRlongTP2 = entryPrice + longRisk * tp2RRlongTP3 = entryPrice + longRisk * tp3RRshortTP1 = entryPrice - shortRisk * tp1RRshortTP2 = entryPrice - shortRisk * tp2RRshortTP3 = entryPrice - shortRisk * tp3RR// Break-even trackingvar bool longTP1Hit = falsevar bool shortTP1Hit = falseif strategy.position_size == 0 longTP1Hit := false shortTP1Hit := falseif strategy.position_size > 0 and high >= longTP1 longTP1Hit := trueif strategy.position_size 0 strategy.exit("LONG EXIT TP1", "LONG", stop=activeLongSL, limit=longTP1, qty_percent=50) strategy.exit("LONG EXIT TP2", "LONG", stop=activeLongSL, limit=longTP2, qty_percent=30) strategy.exit("LONG EXIT TP3", "LONG", stop=activeLongSL, limit=longTP3, qty_percent=20)if strategy.position_size 0 ? activeLongSL : na, "Long Stop", color=color.red, linewidth=2, style=plot.style_linebr)plot(strategy.position_size > 0 ? longTP1 : na, "Long TP1", color=color.lime, style=plot.style_linebr)plot(strategy.position_size > 0 ? longTP2 : na, "Long TP2", color=color.lime, style=plot.style_linebr)plot(strategy.position_size > 0 ? longTP3 : na, "Long TP3", color=color.lime, style=plot.style_linebr)plot(strategy.position_size < 0 ? activeShortSL : na, "Short Stop", color=color.orange, linewidth=2, style=plot.style_linebr)plot(strategy.position_size < 0 ? shortTP1 : na, "Short TP1", color=color.red, style=plot.style_linebr)plot(strategy.position_size < 0 ? shortTP2 : na, "Short TP2", color=color.red, style=plot.style_linebr)plot(strategy.position_size < 0 ? shortTP3 : na, "Short TP3", color=color.red, style=plot.style_linebr)// Alertsalertcondition(longEntry, "LONG ENTRY", "Long entry triggered")alertcondition(shortEntry, "SHORT ENTRY", "Short entry triggered")