Algorithms › US500 Pullback
BetaNew · test on demoversion 1.0
US500 Pullback
Buys sharp short dips in the S&P 500 while it is above its 200-day average, and sells into the bounce. Daily bars, long only.
How it works
Once a day, after the broker's daily close (17:00 New York time at most brokers), the algorithm checks the S&P 500 CFD (US500):
- Uptrend: the close is above its 200-day simple moving average. Below it, the algorithm doesn't buy.
- Sharp dip: the 2-period RSI is below 10, which usually means two or three down days in a row.
When both are true it buys shortly after the daily rollover, once the spread is normal again. Long only.
Exits
- The first close above the 5-day simple moving average: the position is closed after the next rollover.
- Time stop: closed after 10 daily bars if that bounce doesn't come.
- Protective stop 3 x ATR(20, daily) below the entry, sent with the order so it sits on the broker's server.
Risk limits
- Risk per trade from your risk profile, measured to the protective stop (Standard: 0.5% of equity). Most trades exit earlier through the 5-day rule.
- One position at a time; it never adds to a position.
- Daily loss limit: no new entries for the rest of the UTC day. The open position keeps its stop, unless you switch on closing it too.
How it typically behaves
- Trades rarely: only after a sharp drop inside an uptrend. Some months have no trade at all.
- Short holds: usually a few days, never more than 10 daily bars.
- Many small gains, fewer but larger losses. It buys weakness, so when a decline keeps going (the first leg of a crash, like late February 2020) one loss can wipe out several gains. The stop limits that, but a gap over a weekend or on news can go past it.
- In long bear markets the price stays below the 200-day average (most of 2008 and 2022), and it mostly sits out.
Where the rules come from
The 2-period RSI pullback was published by Larry Connors and Cesar Alvarez in "Short Term Trading Strategies That Work" (2008). This is our own implementation of those public rules, with two additions for a leveraged CFD: the protective ATR stop and the time stop.
Costs
The gain per trade is small, so costs matter: the spread on entry and exit, and the overnight financing (swap) for every night held, three nights over a weekend. Check your broker's US500 swap in MT5: Market Watch, right-click, Specification.
New · test on demo
New in the library and not live-proven. The rules are fixed and public; there is no track record yet, so we show no performance figures. Backtest it in the MT5 Strategy Tester on your broker's data and run it on a demo account first.
Parameters
Defaults the EA receives; risk comes from your risk profile.| Parameter | Default | Range |
|---|---|---|
| Risk per trade (% of equity, to the protective stop)Position size is calculated so a hit of the protective stop loses about this much. Most trades exit earlier, at a smaller loss or a gain.risk_percent | 0.5 | 0.05 – 5 |
| Max loss per day (% of start-of-day equity)No new entries for the rest of the UTC day once reached.max_daily_loss_pct | 2 | 0.5 – 10 |
| Max trades per daymax_trades_per_day | 1 | 1 – 3 |
| Daily loss limit also closes the open positionOff: the position keeps its protective stop and normal exits.close_on_daily_loss | Off | on / off |
| Skip if the minimum lot risks more than plannedskip_if_min_lot_too_big | On | on / off |
| Trend filter: moving average (daily bars)Buys only when the close is above this simple moving average.trend_sma_period | 200 | 50 – 400 |
| RSI period (daily bars)rsi_period | 2 | 2 – 5 |
| Entry rulersi: RSI below the entry level. cumulative: the sum of the last two RSI values below the cumulative level.entry_mode | rsi | rsi · cumulative |
| Buy when RSI is belowentry_rsi_below | 10 | 1 – 30 |
| Cumulative rule: buy when the 2-day RSI sum is belowcum_rsi_below | 35 | 5 – 60 |
| Exit: close above the moving average of (daily bars)exit_sma_period | 5 | 3 – 20 |
| Also exit when RSI is above (0 = off)exit_rsi_above | 0 | 0 – 95 |
| ATR period (daily bars)atr_period | 20 | 10 – 50 |
| Protective stop (x daily ATR)Sent with the order, so it sits on the broker's server.stop_atr_mult | 3 | 1.5 – 6 |
| Time stop (daily bars, 0 = off)time_stop_days | 10 | 0 – 30 |
| Max spread (x daily ATR, 0 = off)Waits while the spread is wider, e.g. right after the daily rollover.max_spread_atr | 0.05 | 0 – 0.5 |
| Wait after the daily rollover (minutes)entry_delay_min | 15 | 0 – 120 |
| Entry window after the daily bar opens (hours)An entry not filled by then is skipped.entry_window_hours | 8 | 1 – 20 |