SPY Quant ML + Session Filter Strategy [CocoChoco] by CocoChoco1
By CocoChoco1
Performance Metrics
- Author: CocoChoco1
- Symbol: TVC:SPX
- Timeframe: 1 hour
- Net P&L: +85.20 USD (+0.85%)
- Win Rate: 59.4%
- Profit Factor: 1.138
- Max Drawdown: 129.72 USD (1.28%)
- Total Trades: 337
Description
S&P 500 Quant: Machine Learning & Mean Reversion (Session-Filtered)OverviewThis is a professional-grade quantitative strategy designed specifically for the S&P 500. It combines classical statistical mean reversion (Z-Score) with a modern Machine Learning filter and rigorous institutional-grade risk management.The strategy is optimized for traders who prioritize high win rates and capital preservation, specifically avoiding the "gap risk" associated with holding positions overnight.Core Methodology1. Statistical Entry (The Z-Score Engine)The strategy identifies "oversold" conditions in a bullish context. It calculates the Z-Score of the price relative to its 20-period Mean (SMA). By default, it looks for a -1.2 Standard Deviation extension, signaling a high-probability "dip" ripe for a snap-back to the mean.2. Trend & ML FiltersTo avoid "catching a falling knife," the strategy uses two layers of confirmation:Trend Filter: Only takes Long positions when the price is above the 200-period SMA, ensuring we only buy dips in a confirmed uptrend.ML Correlation Filter: A Machine Learning-inspired module that analyzes the correlation between RSI and Volatility (ATR). It only permits entries when market internal dynamics suggest a reversal is technically "healthy."3. Institutional Risk ManagementThis script is built for "safety-first" automation:Hard Stop Loss: Fixed at 1.5% to protect against sudden market shocks.Active Trailing: A dual-trigger trailing stop. It activates once the price touches the 20 SMA (The Mean) OR once a trade reaches a 0.50% profit threshold. This ensures near-winners are protected and large runners are captured.Intraday Circuit Breaker: Includes a Max Daily Drawdown (2%) limit. If hit, the script automatically closes losing positions and halts trading for the day, while allowing winning positions to continue.Key FeaturesSession-Specific: Tailored for the US Trading Session (UTC/NY times).Zero Overnight Risk: Automatically flattens all positions before the market close (16:00 NY Time).Holiday Intelligence: Hard-coded logic for US Market Holidays and Early Closes (2026–2028), ensuring the bot doesn't get stuck in illiquid holiday markets.Hourly Entry Cap: Limits entries to one per hour to prevent over-concentration during a single price leg.How to UseTimeframe: I suggest you use it on the 5-minute or 1-hour timeframe for optimal results.Instrument: Designed for the S&P 500, but highly effective on SPY, IVV, and ES (Futures).Pyramiding: Designed to handle up to 3 concurrent positions, allowing the strategy to scale into a move as the Z-Score deepens.Automation ReadyThis script is fully compatible with webhook-based automation tools. All signals (Entry, SL, Trail, Market Close, and Daily Limit) are clearly labeled in the Alert comments for seamless execution. I haven't tasted it though. This is not financial advice. Please perform your own tests and manage your risk.DisclaimerPast performance does not guarantee future results. This script is a tool for quantitative analysis and should be used as part of a broader diversified trading plan.