Fair Value Gap - refining but here is first 2 runs
This analysis leverages a Python-based framework to systematically identify and rank Fair Value Gaps (FVGs) in E-mini S&P 500 (ES) 5-minute futures data, drawing from ICT/SMC principles to uncover high-probability setups by dissecting market structure into pre-FVG momentum (trends and volume slopes), during-FVG candle characteristics (body/wick ratios, volume spikes, close positioning), and post-FVG validation (directional slopes, risk-reward projections adjusted for congestion). Through vectorized feature engineering and hyperparameter optimization via Hyperopt, the script computes composite scores—weighting candle strength (20%), pre-context (30%), post-momentum (30%), and RR viability (20%)—to surface top individual FVGs and recurring patterns filtered for at least 2-3 occurrences per week over configurable historical periods (e.g., 1-5 years), ensuring statistical relevance while exporting detailed CSVs for manual review. The generated ThinkOrSwim indicator incorporates a state machine for layered, real-time signal building: idle monitoring transitions to FVG watch (with timeout fail-safes), pullback confirmation (touch tolerance via ATR, volume crosses, and third-of-candle filters), and entry alerts tied to percentage-based TP/SL mechanics, visualizing gaps during active states for trader oversight. While robust in backtesting recurring edges and mitigating false positives through post-alignment inclusion, the system remains a work in progress—particularly in fine-tuning weekly frequency thresholds, integrating deeper displacement counts for "latter" FVGs, and expanding to multi-timeframe confluence—inviting community collaboration on GitHub or trading forums to iterate on edge cases, data robustness, or TOS enhancements for broader adoption.

