//@version=5 strategy("Riley Coleman 1-Minute Futures Reversal Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // --- INPUTS --- htf_period = input.timeframe("15", "HTF Support/Resistance Period") htf_lookback = input.int(20, "HTF Extreme Levels Lookback") fvg_lookback = input.int(5, "Unhealthy Move (FVG) Lookback Window") rr_ratio = input.float(3.0, "Risk to Reward Ratio") use_trailing = input.bool(true, "Use Candle-by-Candle Trailing Stop") trail_bars = input.int(3, "Trailing Stop Lookback Bars") // --- HTF SUPPORT/RESISTANCE --- htf_high = request.security(syminfo.tickerid, htf_period, ta.highest(high, htf_lookback)[1]) htf_low = request.security(syminfo.tickerid, htf_period, ta.lowest(low, htf_lookback)[1]) // Plot high-level support and resistance plot(htf_high, color=color.new(color.red, 30), linewidth=2, title="HTF Resistance Zone") plot(htf_low, color=color.new(color.green, 30), linewidth=2, title="HTF Support Zone") // --- UNHEALTHY MOVE IDENTIFICATION (Fair Value Gaps) --- // Bullish FVG (Unhealthy move to the upside) bull_fvg = (low[0] > high[2]) and (close[1] > high[2]) // Bearish FVG (Unhealthy move to the downside) bear_fvg = (high[0] < low[2]) and (close[1] < low[2]) // Track FVG occurrence bar indexes var int last_bull_fvg_bar = 0 var int last_bear_fvg_bar = 0 if bull_fvg last_bull_fvg_bar := bar_index if bear_fvg last_bear_fvg_bar := bar_index bull_fvg_active = (bar_index - last_bull_fvg_bar) <= fvg_lookback bear_fvg_active = (bar_index - last_bear_fvg_bar) <= fvg_lookback // Highlight overextended moves plotshape(bull_fvg, title="Bullish FVG (Overextended Up)", style=shape.triangledown, location=location.abovebar, color=color.yellow, size=size.small) plotshape(bear_fvg, title="Bearish FVG (Overextended Down)", style=shape.triangleup, location=location.belowbar, color=color.fuchsia, size=size.small) // --- REVERSAL CONDITIONS --- near_resistance = high >= htf_high near_support = low <= htf_low // Reversal triggers when price rejects and sweeps previous candle structural structures short_trigger = near_resistance and bull_fvg_active and close < low[1] long_trigger = near_support and bear_fvg_active and close > high[1] // --- TRADE EXECUTION --- var float sl_level = na var float tp_level = na if short_trigger and strategy.position_size == 0 sl_level := ta.highest(high, 5) risk_dist = sl_level - close tp_level := close - (risk_dist * rr_ratio) strategy.entry("Short Reversal", strategy.short) strategy.exit("Short Exit", "Short Reversal", stop=sl_level, limit=tp_level) if long_trigger and strategy.position_size == 0 sl_level := ta.lowest(low, 5) risk_dist = close - sl_level tp_level := close + (risk_dist * rr_ratio) strategy.entry("Long Reversal", strategy.long) strategy.exit("Long Exit", "Long Reversal", stop=sl_level, limit=tp_level) // --- TRAILING STOP LOGIC --- if use_trailing and strategy.position_size != 0 if strategy.position_size < 0 // Trailing short using the highest high of recent candle bars trail_stop = ta.highest(high, trail_bars) strategy.exit("Short Exit", "Short Reversal", stop=trail_stop) else if strategy.position_size > 0 // Trailing long using the lowest low of recent candle bars trail_stop = ta.lowest(low, trail_bars) strategy.exit("Long Exit", "Long Reversal", stop=trail_stop)