//@version=5 strategy("7PM FVG Trading Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05) // Inputs i_session = input.session("1900-2345:23456", "Trading Session (7PM-12AM IST)", tooltip="Session timeframe and active days (Mon-Fri)") i_timezone = input.string("Asia/Kolkata", "Session Timezone") i_rr = input.float(2.0, "Risk to Reward Ratio", minval=0.5, step=0.5) // Time Filter in_session = !na(time(timeframe.period, i_session, i_timezone)) // FVG Detection (3-Bar Pattern) // Bullish FVG: Low of current bar > High of 2 bars ago bull_fvg = (low[0] > high[2]) and (close[1] > open[1]) // Bearish FVG: High of current bar < Low of 2 bars ago bear_fvg = (high[0] < low[2]) and (close[1] < open[1]) var float fvg_top = na var float fvg_bot = na var int fvg_type = 0 // +1 for Bullish, -1 for Bearish var bool fvg_valid = false // Reset active state when outside session if not in_session fvg_valid := false fvg_type := 0 // Capture FVG formed within session if in_session and not fvg_valid if bull_fvg fvg_top := low[0] fvg_bot := high[2] fvg_type := 1 fvg_valid := true else if bear_fvg fvg_top := low[2] fvg_bot := high[0] fvg_type := -1 fvg_valid := true // Entry Execution on Gap Retest if in_session and fvg_valid and strategy.position_size == 0 if fvg_type == 1 and low <= fvg_top and close >= fvg_bot entry_price = close sl = fvg_bot risk = entry_price - sl if risk > 0 tp = entry_price + (risk * i_rr) strategy.entry("Long FVG", strategy.long) strategy.exit("Exit Long", "Long FVG", stop=sl, limit=tp) fvg_valid := false else if fvg_type == -1 and high >= fvg_bot and close <= fvg_top entry_price = close sl = fvg_top risk = sl - entry_price if risk > 0 tp = entry_price - (risk * i_rr) strategy.entry("Short FVG", strategy.short) strategy.exit("Exit Short", "Short FVG", stop=sl, limit=tp) fvg_valid := false // Visualizations plot(fvg_valid and fvg_type == 1 ? fvg_top : na, "Bull FVG Top", color=color.green) plot(fvg_valid and fvg_type == 1 ? fvg_bot : na, "Bull FVG Bottom", color=color.lime) plot(fvg_valid and fvg_type == -1 ? fvg_top : na, "Bear FVG Top", color=color.red) plot(fvg_valid and fvg_type == -1 ? fvg_bot : na, "Bear FVG Bottom", color=color.orange)