//@version=5 strategy("TJR Updated Day Trading Strategy (2026)", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // --- Inputs --- london_session = input.string("0200-0800", title="London Session (Range Definition)") ny_session = input.string("0930-1600", title="NY Trading Session (Execution Window)") rr_ratio = input.float(1.33, title="Risk to Reward Ratio") fvg_offset = input.float(0.0, title="FVG Entry Buffer (Ticks/Pips)") // --- Session Logic --- in_london = not na(time(timeframe.period, london_session + ":23456", "UTC-5")) in_ny = not na(time(timeframe.period, ny_session + ":23456", "UTC-5")) var float london_high = na var float london_low = na // Reset & track London high/low if in_london if na(london_high) or high > london_high london_high := high if na(london_low) or low < london_low london_low := low else if not in_london and not in_ny // Clear levels outside of execution/london times to prepare for next day london_high := na london_low := na // Plot London Ranges plot(london_high, title="London Session High", color=color.red, style=plot.style_line, linewidth=1) plot(london_low, title="London Session Low", color=color.green, style=plot.style_line, linewidth=1) // --- Strategy Variables --- var bool sweep_high_detected = false var bool sweep_low_detected = false var float sweep_high_price = na var float sweep_low_price = na var float mss_level = na var int state = 0 // 0 = Idle, 1 = Swept, 2 = MSS Confirmed, 3 = Order Placed // Reset states daily at market close or outside trading hours if not in_ny sweep_high_detected := false sweep_low_detected := false sweep_high_price := na sweep_low_price := na mss_level := na state := 0 // --- Liquidity Sweep (Step 1) --- if in_ny and state == 0 if not na(london_high) and high > london_high and close < london_high sweep_high_detected := true sweep_high_price := high mss_level := ta.lowest(low, 5)[1] // Setup Market Structure Shift Level (Swing Low of sweep structure) state := 1 if not na(london_low) and low < london_low and close > london_low sweep_low_detected := true sweep_low_price := low mss_level := ta.highest(high, 5)[1] // Setup Market Structure Shift Level (Swing High of sweep structure) state := 1 // --- Market Structure Shift & FVG Check (Step 2 & 3) --- var float entry_price = na var float stop_loss = na var float take_profit = na if in_ny and state == 1 if sweep_high_detected // MSS Confirmation: Close below Swing Low if close < mss_level state := 2 // Identify Bearish FVG within the shift leg if possible, else use Equilibrium (50% level) bool bearish_fvg = (high[0] < low[2]) and (close[1] < open[1]) if bearish_fvg entry_price := low[2] - fvg_offset else entry_price := (sweep_high_price + close) / 2.0 // Equilibrium stop_loss := sweep_high_price take_profit := entry_price - (stop_loss - entry_price) * rr_ratio if sweep_low_detected // MSS Confirmation: Close above Swing High if close > mss_level state := 2 // Identify Bullish FVG within the shift leg if possible, else use Equilibrium (50% level) bool bullish_fvg = (low[0] > high[2]) and (close[1] > open[1]) if bullish_fvg entry_price := high[2] + fvg_offset else entry_price := (sweep_low_price + close) / 2.0 // Equilibrium stop_loss := sweep_low_price take_profit := entry_price + (entry_price - stop_loss) * rr_ratio // --- Trade Execution (Step 4) --- if in_ny and state == 2 if sweep_high_detected strategy.entry("TJR Short", strategy.short, limit=entry_price) strategy.exit("Short Exit", "TJR Short", stop=stop_loss, limit=take_profit) state := 3 if sweep_low_detected strategy.entry("TJR Long", strategy.long, limit=entry_price) strategy.exit("Long Exit", "TJR Long", stop=stop_loss, limit=take_profit) state := 3 // Cancel pending limit orders if session ends if not in_ny and state == 3 strategy.cancel_all() state := 0