Skip to main content

gap detection filter preventing losses

added gap detection after august 14 loss.

been running it 4 days.

already proving useful.

the filter logic
#

skip trading if:

  • market gaps >1% at open
  • within 2 hours of gap open
  • regardless of vol detection status

reasoning: gaps create new price ranges. entering against gap momentum = fighting tape.

implementation
#

async def check_gap_filter(self, symbol: str) -> bool:
    """Check if gap is too large to trade"""

    # Get today's open and yesterday's close
    today_open = await self.get_today_open(symbol)
    yesterday_close = await self.get_yesterday_close(symbol)

    # Calculate gap %
    gap_pct = abs((today_open - yesterday_close) / yesterday_close)

    if gap_pct > 0.01:  # 1% gap threshold
        # Check time since open
        market_open_time = self.get_market_open_time()
        current_time = datetime.now()
        hours_since_open = (current_time - market_open_time).seconds / 3600

        if hours_since_open < 2:
            logger.warning(f"BLOCKED: {symbol} - gap {gap_pct:.2%}, only {hours_since_open:.1f}h since open")
            return False

    return True

this week’s saves
#

monday 8/14: (the loss that triggered this filter)

  • 1.2% gap up at open
  • entered at 10:30am (1 hour after open)
  • lost -$360
  • with new filter: would’ve been blocked

wednesday 8/16:

  • 1.4% gap down at open
  • filter blocked SPX entry at 10:45am
  • position would’ve stopped: -$340
  • saved: $340

friday 8/18:

  • 1.1% gap up at open
  • filter blocked QQQ entry at 11:00am
  • position would’ve stopped: -$295
  • saved: $295

total saved in 4 days: $635 (would’ve been $995 if counted original loss)

tradeoff analysis
#

blocked trades: 3

  • 2 would’ve lost: -$635
  • 1 would’ve won: +$280

net benefit: +$355

worth it.

filter stack growing
#

current entry filters (all must pass):

  1. vol detection (blocks elevated/spike regimes)
  2. correlation limit (max 2 equity positions)
  3. time-of-day (skip first 30 min)
  4. gap detection (skip 2h after >1% gap)

each filter removes bad trades.

stacking them = higher win rate.

august week 4 preview
#

week 1: +$2,065 week 2: +$1,805 week 3: +$1,705 current: +$5,575

need $425 more to hit $6k august.

1 week left. easy.

momentum strategy
#

continuing at 0.5% risk.

total momentum trades: 4 (all wins)

win rate: 100% (4/4)

profit factor: infinite (no losses yet)

obviously not sustainable but good start.

account status
#

start august: $351,145 current aug 18: $356,720 gain: +$5,575 (+1.59%)


2:52pm friday. gap filter working. saved $635 in first 4 days. filter stack preventing bad trades. august continues strong.

-AK

Related

analyzed correlation between my strategies - found hidden risk
ran correlation analysis on my strategies. found something i didn’t expect. what i analyzed # all trades from may-july (3 months, 65 trades).
testing tighter stops - early results mixed
started testing tighter stop losses today. goal: reduce avg loss from $660 to $600. early results: mixed. the change # old stops: -150% of credit received
lost one, saved three - vol detection paying off
thursday was rough but could’ve been way worse. what happened # thursday 6/8: TLT put spread: -$315 (stopped during bond market dump) account: $341,720 → $341,405 lost $315 on one trade. sucks but manageable.
IB increased my margin - didn't ask for it
woke up to email from interactive brokers. “Your account has been approved for portfolio margin” didn’t apply for it. they just gave it to me. what is portfolio margin # reg-t margin (what i have now):
correlation risk - learned the hard way
lost $1,400 yesterday because i didn’t track correlation between my positions. dumb mistake. what happened # may 10, 2pm:
may day 1 - smaller position sizes
cut position sizes in half. only trading 3 strategies now. first day of may went… fine? +$180 on one trade. nothing else triggered. new risk rules # old position sizing: 2.5% risk per trade = $850 max loss (on $340k account)