S&P Order Block Retest
A rule-based intraday strategy for the S&P 500. It builds its own 30-minute bars from 18:00 ET, whatever the chart timeframe.
- Market
- the S&P 500, under the names it trades as.
- Runs on
- ES1! or MES1!, or an index / CFD feed of one of the names above that quotes the whole 18:00-17:00 ET session, on a 5-minute chart (recommended).
Free on request during the launch period.
Open on TradingViewThe rules, in full
- Bars: the session (18:00-17:00 ET) is cut into 30-minute bars counted from 18:00 ET. A swing high (low) is a 30-minute bar whose high (low) is above (below) both neighbours. It can be used once the next bar has closed. The scan starts once 25 bars of the session have closed and reruns at every 30-minute close.
- Break: a 30-minute close above the last unbroken swing high breaks it. The break counts as a signal bar only if all of these hold:
- it ends between 09:30 and 14:30 ET;
- at least 20 earlier 30-minute bars exist in the session;
- its range is at least 2.0 x the median range of the previous (up to 50) 30-minute bars.
Any close above the swing high uses that swing up, even if the bar is not large enough.
- Order block (long): the origin is the lowest low between the swing high and the break bar. The order block is the last down-close bar from the origin bar back up to 10 bars, together with any down-close bars right before it (within the same 10 bars). If there is no down-close bar, there is no setup. The zone runs from the lowest low to the highest high of those bars.
- Sweep: the origin low must be below the previous swing low. The break bar must close above the order block high.
- Entry: buy limit at the order block high, placed when the signal bar closes. The order is valid until 15:00 ET and fills only when price trades 1 tick through the level. Shorts mirror all of this: the order block is an up-close bar and a sell limit sits at its low.
- Only the first setup of the day is used: one order and at most one trade per day. If a long and a short setup appear, the earlier one is used (long on a tie); there is never a position on both sides.
- Stop: 1 tick beyond the far side of the order block. The distance from the entry is kept between 0.03 U and 0.60 U, where U is the median full-session range of the prior 20 normal sessions. If U is not available, the day is skipped.
- Exit: there is no target. The trade is closed at market 30 minutes after the fill, unless the stop is hit first. Because the order expires at 15:00 ET, the last exit is about 15:30 ET.
That is the whole rule set, exactly as published. Nothing is held back for subscribers.
What you see on the chart
- Green ▲ LONG label below the signal bar or red ▼ SHORT label above it. Hover for the order block, limit price, stop and exit rule; after the fill it shows the fill price. If the limit is not reached by 15:00 ET the label turns grey and reads "not filled" (no trade). The Strategy Tester's own entry arrow marks the fill bar.
- Light orange box over the order block (on accepted S&P 500 symbols only). It extends while the order or the trade is live.
- While the order is working or the trade is open: a white line at the limit/entry price, a red stop line and a light red zone between them. Each line is named with its price at the right end (Limit / Entry, Stop).
- "EXIT +/- pts" label at each exit. Hover for the reason (Stop, Time exit, Session end) and the P/L.
- Light blue shading while the signal window is open, and a green or red background on the signal bar.
- Compact status box (top right): the symbol and how it was read (S&P 500 futures / index / CFD / ETF); the state (WAITING, SETUP with the limit price, IN LONG / IN SHORT with the exit time, DONE with the reason, OFF on a wrong symbol or timeframe), the key levels (swing levels being watched, or limit/entry and stop), and the signal count, the trade count (same as the Strategy Tester) and days loaded; plus an orange row on a non-futures symbol about Properties (CFD) or about the missing 18:00 ET session (ETF). Hover a row for more. Turn on "Show details" for U and the stop limits, the time windows, the exit rule and the last setup.
- Red banner on any symbol that is not an S&P 500 instrument (no orders unless the market lock is overridden). Orange banner in the middle of the chart on an unsupported timeframe, naming the 5-minute chart. Small yellow tip on supported charts other than 5-minute.
Alerts
1. Add the strategy to a 5-minute chart of an S&P 500 symbol - ES1!, MES1!, SPX500, US500...
2. Create Alert: Condition = this strategy, then "alert() function calls only". TradingView calls this a technical alert, and a free Basic account cannot create one - Basic allows 3 price alerts and no technical alerts at all, so the Create Alert dialog will not let you save it. Essential is the lowest plan that works (20 technical alerts); Plus 100, Premium 400. On Essential and Plus an alert also expires after two months and has to be created again; on Premium and Ultimate it does not expire. Phone notifications themselves are free on every plan - tick "Notify on app" and have the TradingView app installed and signed in on the same account.
3. Each message is one short line: what happened and at what price first, then the exchange and ticker, then the extras separated by "|". Nothing else to read.
LONG LIMIT 6012.25 on CME_MINI:ES1! | SL 5998.50 | no TP | exit 30 min after fill | valid till 15:00 ET
LONG FILLED 6012.25 on CME_MINI:ES1! | SL 5998.50 | no TP | exit by 10:35 ET
EXIT 6020.00 on CME_MINI:ES1! | Stop | +7.75 pts | position 0
EXIT 6005.50 on OANDA:SPX500USD | Time exit | -6.75 pts | position 0
The ticker is in every line, so you can watch several S&P 500 symbols at once and still tell them apart at a glance. Alerts are per chart: create one on each symbol you want watched.
4. Messages fire once per bar close. Three toggles in the Alerts group: the limit order, the fill and the exit.
5. On a free Basic account, which has no technical alerts, use the last status-box row and a free price alert on the symbol. Once a setup forms it shows one number: the working limit, which is the order-block boundary the rule waits to see retested - the entry price itself, known in advance. Before that it shows the swing high and low the break is measured against, marked "(break, not entry)": reaching one of those only starts a setup. Either way it means price arrived, not that the strategy traded, so open the chart before acting.
Settings
- Setup: displacement multiple 2.0, median lookback 50 bars, sweep required, first signal bar end 09:30 ET, order expiry 15:00 ET.
- Stop and exit: stop distance 0.03 to 0.60 x U, time exit 30 minutes after the fill, flat by 16:10 ET, U from 20 sessions (oldest within 40 days).
- These defaults define the strategy. Changing them changes the strategy.
- Market lock: "Override market lock (allow non-S&P symbols)" (off by default). The S&P 500 is recognised by its contract root or ticker together with the instrument type: futures with the root ES or MES; index, CFD or forex-type feeds whose ticker starts with SPX, US500, SP500 or USA500; and the four ETFs SPY, VOO, IVV, SPLG. Everything else - including S&P-tracking leveraged or sector ETFs and any other ticker - is refused. Turn the override on only to experiment elsewhere; the session requirement still applies, so a symbol without an 18:00 ET start will still produce nothing.
- Alerts, Display Options and Colors.
- Properties default to 100,000 initial capital, 1 contract, 0.95 commission per contract per side (micro), 1 tick slippage, 5% margin and no pyramiding. Enter your own size and cost for the instrument you trade - these defaults are wrong for full-size ES, for an index CFD (where 1 contract is 1 index point) and for an ETF.
Limits, and what this cannot do
- Pine estimates the price path inside each bar, and stops are judged from bar high and low. If a bar opens beyond the limit price, Pine fills at that open. Results on chart bars can differ from live fills.
- The time exit is placed at the open of the first bar that starts 30 minutes or more after the fill bar opened. That can be up to one chart bar earlier than exactly 30 minutes after the fill.
- Different S&P 500 symbols are different data: a CFD feed, a futures contract and an ETF do not print the same bars, do not keep the same hours and do not start their daily bar at the same time, so the same rule produces a different trade list on each. Read each one on its own chart.
- U is built from 15-minute bars (30-minute bars on a 30-minute chart) and needs about one month of history. On futures use a continuous contract (ES1! / MES1!); roll adjustment can shift U.
- The chart data must start at 18:00 ET for a session to count. That rules out the S&P 500 ETFs and the cash index entirely, and it rules out any CFD feed that pauses overnight or is set to regular trading hours. Early-close days use the normal 15:00 / 16:10 ET times; change them by hand.
- The script only sees its own trades.
Educational tool. Not financial advice. Past behaviour does not predict future results.
Before you decide
The script page on TradingView carries TradingView's own Strategy Tester report, generated by TradingView from this script. We do not write those numbers and we do not repeat them here. Read them at the source: S&P Order Block Retest on TradingView.