Enhanced Multi-Signal Mean Reversion on TSLA — Alpaca Paper Account · Extended Hours
A mean reversion equity strategy that buys TSLA when multiple indicators signal an oversold extreme and exits when price reverts toward its mean. The script runs a continuous polling loop every 60 seconds during the extended session (4:00 AM – 8:00 PM ET) and uses the Alpaca market calendar to automatically skip weekends and holidays.
The TSLA version uses a slightly higher RSI entry threshold (35 vs 30 for SPY) and a
weighted confirmation score of ≥ 1.5 before entering — reflecting TSLA’s higher
individual-stock volatility. Maximum shares held at any time: 100. All orders are limit
orders at the current bid (sells) or ask (buys) with extended_hours=True.
| Parameter | Value | Description |
|---|---|---|
| Ticker | TSLA | Underlying equity |
| Bar size | 1-minute bars | Granularity for all indicators |
| RSI period | 14 | Look-back window |
| Entry RSI threshold | < 35 | Oversold entry |
| Exit RSI threshold | > 55 | Mild overbought exit |
| Position size | 95% of cash | Per entry |
| Max shares | 100 | Cap across all entries |
| Stop-loss | 0.5% | Below weighted avg entry |
| Session hours | 4:00 AM – 8:00 PM ET | Extended hours |
| Poll interval | 60 s | Continuous loop during session |
| Order type | Limit | Bid for sells, ask for buys |
An entry is triggered when RSI(14) < 35 (required) and confirmation score ≥ 1.5:
| Signal | Score | Condition |
|---|---|---|
| MACD ↑ | +1.0 | MACD histogram rising vs prior bar |
| BB touch | +1.0 | Price ≤ lower Bollinger Band (2 std below 20-bar MA) |
| BB mid | +0.5 | Price ≤ middle Bollinger Band (below mean) |
| Volume | +1.0 | Current volume ≥ 0.5× its 20-bar MA |
| Trigger | Condition |
|---|---|
| Stop-loss | Price ≤ entry × 0.995 (−0.5%) |
| RSI overbought | RSI > 55 |
| BB upper | Price ≥ upper Bollinger Band |
| MACD fading | MACD histogram falling AND RSI > 55 |
20-bar SMA of volume. Entry requires current volume ≥ 0.5× this average (VOLUME_MULTIPLIER=0.5).
| Variable | Default | Description |
|---|---|---|
SYMBOL | TSLA | Ticker |
RSI_PERIOD | 14 | RSI look-back |
RSI_OVERSOLD | 35 | Entry threshold |
RSI_OVERBOUGHT | 55 | Exit threshold |
POSITION_SIZE_PCT | 0.95 | Cash fraction per entry |
MAX_SHARES | 100 | Max total shares held |
STOP_LOSS_PCT | 0.005 | 0.5% stop-loss |
LOOKBACK_DAYS | 3 | Calendar days of bars |
INTERVAL_SECONDS | 60 | Poll interval |
TRADING_START_HOUR | 4 | Session start (ET) |
TRADING_END_HOUR | 20 | Session end (ET) |
VOLUME_MULTIPLIER | 0.5 | Volume gate fraction |
USE_PAPER | True | Paper vs live trading |
| Event | Time (ET) | Days |
|---|---|---|
| Session start | 4:00 AM | Mon–Fri |
| Session end | 8:00 PM | Mon–Fri |
| Poll interval | Every 60 s | During session |
| Stale order cancel | Start of every pass | — |
| Market calendar refresh | Once per calendar day | — |
Each pass: cancel unfilled limit order → fetch 1-min bars (3 days) → compute indicators → check exit → check entry.
Trading keys loaded from alpaca table (acctname = 'Aiv010'); data keys from data_key table (name = 'DanSavage1P1'). Connection details read from strategies-single/.env.
TSLA is significantly more volatile than SPY. Intraday moves of 5–10%+ are common around earnings, macro events, or news. The 0.5% stop-loss limits individual loss per trade but does not protect against gap opens or rapid moves that skip the limit price.
The strategy can add to an existing position on subsequent signals up to MAX_SHARES=100. Weighted average entry price is maintained across adds. All shares are sold together on any exit trigger.
strategies-single/.envLogs are written to both stdout and strategies-single/logs/mean_reversion.log. Key log lines per pass include RSI, MACD histogram, Bollinger Bands, and P&L on exits.
This strategy runs on an Alpaca paper trading account. Set USE_PAPER = False at your own risk. Past performance does not guarantee future results.
This strategy trades TSLA multiple times a day and will trigger the Pattern Day Trader (PDT) flag, which requires you to maintain a balance of $25,000 in your account.
A pattern day trader is defined by FINRA as any trader who executes four or more day trades within five business days in a margin account, where those trades represent more than 6% of their total trading activity during that period. Once flagged, your account must maintain a minimum equity of $25,000 on any day you trade; failure to do so will restrict the account to closing transactions only.
Ensure your Alpaca paper account reflects at least $25,000 equity before running this strategy to avoid PDT restrictions during testing.