This strategy focuses on liquidity sweeps during active market sessions and only trades when the overall trend agrees. The goal is to avoid random entries and concentrate on moves that happen after stop orders are cleared.
How It Works
Liquidity Sweep
Price moves above a recent high or below a recent low during a session, hinting that stops were taken.
Trend Check
A simple trend filter confirms whether the market direction supports the move.
Confirmed Entries
Trades are placed only after the candle closes, so results stay realistic and non-repainting.
Risk Handling
- Stop-loss and take-profit levels are based on ATR, so they adapt to volatility.
- Risk and reward stay consistent even when the market speeds up or slows down.
- Position size can be set as a percentage of equity.
Why This Approach Helps
- Fewer trades, better structure
- Less noise during sideways markets
- More realistic backtest behavior
Reminder
This strategy is meant for testing and learning, not guaranteed results. Always forward-test before using it with real money.
//@version=6
strategy(
"Small Logic Change → Big P&L Difference",
overlay = true,
initial_capital = 100000,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 5
)
// INPUTS
fastLen = input.int(20, "Fast EMA")
slowLen = input.int(50, "Slow EMA")
atrLen = input.int(14, "ATR Length")
riskATR = input.float(1.5, "Stop Loss ATR")
rr = input.float(2.0, "Risk Reward")
useConfirmedBars = input.bool(true, "Use Confirmed Bars")
// INDICATORS
emaFast = ta.ema(close, fastLen)
emaSlow = ta.ema(close, slowLen)
atrVal = ta.atr(atrLen)
// TREND CONTEXT
trendUp = emaFast > emaSlow
trendDown = emaFast < emaSlow
// ✅ CROSS LOGIC (GLOBAL — ALWAYS EXECUTES)
emaCrossUp = ta.crossover(emaFast, emaSlow)
emaCrossDown = ta.crossunder(emaFast, emaSlow)
// ENTRY CONDITIONS
rawLong = trendUp and emaCrossUp
rawShort = trendDown and emaCrossDown
longCond = useConfirmedBars ? (rawLong and barstate.isconfirmed) : rawLong
shortCond = useConfirmedBars ? (rawShort and barstate.isconfirmed) : rawShort
// ENTRIES
if longCond and strategy.position_size == 0
strategy.entry("Long", strategy.long)
if shortCond and strategy.position_size == 0
strategy.entry("Short", strategy.short)
// RISK MANAGEMENT
longSL = strategy.position_avg_price - atrVal * riskATR
longTP = strategy.position_avg_price + atrVal * riskATR * rr
shortSL = strategy.position_avg_price + atrVal * riskATR
shortTP = strategy.position_avg_price - atrVal * riskATR * rr
strategy.exit("Long Exit", "Long", stop = longSL, limit = longTP)
strategy.exit("Short Exit", "Short", stop = shortSL, limit = shortTP)
// VISUALS
plot(emaFast, color=color.orange, title="Fast EMA")
plot(emaSlow, color=color.blue, title="Slow EMA")
Top comments (0)