NinjaTrader 8 Prior-Day High/Low Breakout Strategy: free code and honest test
A breakout of yesterday's range, one trade a day, written for NinjaTrader 8 and tested on five years of MNQ data. It has the best result of our first ten strategies, so read the caveats too.
The idea
Yesterday's high and low are levels many traders watch. If price closes above yesterday's high (or below its low), the strategy treats it as the market accepting a new range and trades that direction, once per day.
In plain English
Before the session opens, the strategy already knows two numbers: yesterday's high and yesterday's low. Once a 5-minute bar closes beyond one of them, it trades in that direction, once per day, with a stop two ATRs away and no target. It stays in until the stop is hit or the end-of-day exit at 15:55. Most trades lose a little; the idea is that a few days move far enough to pay for the rest.
The exact rules
- Chart: MNQ, 5-minute bars, default CME US Index Futures ETH trading hours.
- Levels = the previous regular session's high and low (09:30 to 16:00 Eastern).
- The first 5-minute bar that closes above the prior high buys; the first that closes below the prior low sells short. One trade per day.
- Stop loss: 2 x ATR(14). No profit target; flat from 15:55.
- Last entry 15:30. No overnight trades.
Test results (MNQ, 5 years)
Result: the best of our first ten strategies, but read the caveats. It made $11,863 on 1,028 trades (profit factor 1.17, average $12 a trade) with a worst drawdown of $3,231, and every one of the 6 calendar years was positive (the weakest, 2025, made only $120). That is about $2,373 a year on one micro contract. Caveats: it wins only 30% of its trades, so most trades lose and a few large winners carry it; without its five best trades the total is $6,156, and without the best ten it is $2,242. Longs made $11,293 and shorts only $570: MNQ rose a lot over these five years, which helps a strategy that mostly buys breakouts, and a flat or falling market could look very different. This is a result worth testing further, not proof of an edge.
| With costs | Costs ignored | |
|---|---|---|
| Net profit | $11,863 | $13,960 |
| Number of trades | 1,028 | 1,028 |
| Winning trades | 29.8% | 29.9% |
| Profit factor | 1.17 | 1.20 |
| Average trade | $12 | $14 |
| Worst drawdown | -$3,231 | |
| Net without its 5 best trades | $6,156 |
Results are in US dollars for one MNQ contract. "Costs ignored" is shown only so you can see how much costs matter; it is not what you would have received.
Equity curve
The chart is the sum of every simulated trade in order. It shows what the totals above hide: how long the account spent below its previous high (up to 193 trading days at worst), and how much of the result arrived in a short stretch. Among all 25 strategies in our free pack, this one ranks #2 for net profit and #1 for profit factor after costs. The full comparison is on the strategy hub page.
Three real trades, step by step
These come straight from the simulation, so you can check what a trade looks like in practice. NinjaTrader stamps each 5-minute bar with its closing time, so times below are bar-close times in Eastern, and the end-of-day exit shows as 15:55 or 16:00. The average winning trade made $271 and the average losing trade lost $98.
- Best trade of the five years: on April 9, 2025 at 13:30 Eastern it bought MNQ at 18386.00 and was out at 19326.25 at 16:00, a move of +940.25 points, which is +$1,880 after costs on one contract.
- Worst trade: on August 5, 2024 at 09:40 Eastern it sold short MNQ at 17677.25 and was stopped out at 17861.36 within the same 5-minute bar, a move of -184.11 points, which is -$369 after costs on one contract.
- A typical (median) trade: on October 30, 2023 at 09:45 Eastern it bought MNQ at 14426.75 and was out at 14394.14 at 10:20, a move of -32.61 points, which is -$66 after costs on one contract.
When it made and lost money
Slicing trades by the hour they were entered and the day of the week. Entry hours are Eastern time. Its best entry hour by net was 09:35 (+$5,167) and its worst was 14:00 (-$1,274); its best weekday was Thursday (+$6,339) and its worst was Monday (-$4,227). With a few hundred or a few thousand trades split this many ways, the groups are small, so treat these as observations to study, not as rules to filter your trading by.
| Entry hour (Eastern) | Trades | Winners | Net | Avg per trade |
|---|---|---|---|---|
| 09:35 to 09:59 | 671 | 24% | $5,167 | $8 |
| 10:00 to 10:59 | 194 | 39% | $3,372 | $17 |
| 11:00 to 11:59 | 52 | 42% | $1,418 | $27 |
| 12:00 to 12:59 | 38 | 39% | $104 | $3 |
| 13:00 to 13:59 | 33 | 55% | $2,565 | $78 |
| 14:00 to 14:59 | 19 | 26% | -$1,274 | -$67 |
| 15:00 to 15:59 | 20 | 55% | $513 | $26 |
1 trades fall in buckets too small to show (for example the first minutes of the Sunday evening session); they are included in every total on this page.
| Weekday | Trades | Winners | Net | Avg per trade |
|---|---|---|---|---|
| Monday | 196 | 21% | -$4,227 | -$22 |
| Tuesday | 213 | 31% | $1,818 | $9 |
| Wednesday | 212 | 26% | $1,688 | $8 |
| Thursday | 206 | 36% | $6,339 | $31 |
| Friday | 194 | 36% | $6,260 | $32 |
| Sunday | 6 | 0% | -$12 | -$2 |
1 trades fall in buckets too small to show (for example the first minutes of the Sunday evening session); they are included in every total on this page.
Long trades versus short trades
Longs: 579 trades, $11,293 net, 31% winners. Shorts: 449 trades, $570 net, 28% winners. Both sides made money, which is a better sign than a result that depends on one direction, though it is still one instrument over one period.
Year by year
| Year | Net (with costs) | Trades |
|---|---|---|
| 2021 (from October) | $1,499 | 57 |
| 2022 | $4,736 | 224 |
| 2023 | $2,081 | 216 |
| 2024 | $1,332 | 206 |
| 2025 | $120 | 159 |
| 2026 (to October) | $2,095 | 166 |
Cost stress test
| Cost assumption | Net | Profit factor |
|---|---|---|
| Base costs: $0.50 per side + 1 tick slippage | $11,863 | 1.17 |
| Double commission ($1.00 per side) + 2 ticks slippage | $10,152 | 1.14 |
| $1.00 per side + 3 ticks slippage | $9,258 | 1.13 |
Real fills are often worse than a simulation, so we also ran the same trades with higher commission and more slippage. A strategy whose result disappears here is too thin to trade.
How we tested. This is our own simulation, run in Python on NinjaTrader 1-minute MNQ bars from October 2021 to October 2026 (1,466 trading days), built into 5-minute bars. Signals are read at the close of a bar and filled at the open of the next bar. Costs: $0.50 commission per side plus one tick of slippage on every market or stop fill, 1 contract, regular trading hours only, everything flat by 15:55 Eastern. Targets fill only when price trades one tick through them, and if one bar touches both the stop and the target the stop counts first. The settings are the textbook defaults, chosen before the test and never optimised. The table above is not a NinjaTrader Strategy Analyzer run, so your own backtest will differ somewhat. As a check, we ran six of these strategies (EMA Cross, Keltner, opening range breakout, Fibonacci, Renko-style and Ichimoku) in Strategy Analyzer on MNQ 03-26, 5-minute bars, 5 January to 10 March 2026, with no commission or slippage, and compared them with our simulation over the same dates: trade counts were within 5% and win rates within about 3 percentage points. That check covers those six strategies over about ten weeks, not the whole pack or the whole five years. Run your own before you trust anything.
Watch the test (3:51)
The rules, the result, and three attempts to break it, with the same numbers as this page. Captions only, no voiceover.
Simulated results, not trading results. Education only, not financial advice. Pressing play loads the video from YouTube (privacy-enhanced mode); see the privacy policy. Watch on YouTube instead.
How to use it in NinjaTrader 8
- Download the
.csfile above and save it toDocuments\NinjaTrader 8\bin\Custom\Strategies. - In NinjaTrader choose New → NinjaScript Editor, then press F5 to compile. Compiling reloads all your NinjaScript, so do it when you have no open position and nothing running live.
- To backtest, open New → Strategy Analyzer, choose VortexPriorDayBreakout, set the instrument to MNQ and a 5 Minute data series, pick a date range and run it.
- To run it on a chart, right-click the chart, choose Strategies, add VortexPriorDayBreakout, set the account and order quantity, and tick Enabled. Start on a simulated account.
- Backtest on a single contract month such as MNQ 03-26, or on a correctly merged series. In our testing a merged
MNQ ##-##series returned no trades in Strategy Analyzer, while a single contract worked. - Times in the settings use your chart's time zone. The defaults assume US Eastern time, so change them if your PC clock is in another zone.
- Use the default CME US Index Futures ETH trading hours. When you backtest across a contract roll, use a back-adjusted merged contract: on unadjusted data the roll gap looks like a fake breakout. Our test skipped the day after each roll.
Settings
| ATR period / stop multiple | 14 / 2.0 |
|---|---|
| Trade from / Last entry / Flat by | 093500 / 153000 / 155500 |
Questions
Is this strategy profitable?
See the results above, which are simulated, include costs and are shown exactly as they came out. A simulation does not predict the future, and we do not claim this strategy makes money.
Can I use it on a prop firm account?
Check your firm's rules first. Many prop firms ban automated trading, and breaking that rule can cost you your account. We do not know your firm's current rules.
Why do the results not match my NinjaTrader backtest?
Our results come from our own simulation with the fill rules stated above, not from Strategy Analyzer. Fill assumptions, data and time zones differ, so results will differ. Always run your own test.
Can I change it?
Yes. It is plain NinjaScript with the source included, so you can edit it or learn from it. Changing the settings to fit past data usually makes the past look better and the future no better, so be careful.
How much does it cost?
Nothing. It is free. If you like free tools, see the free Drawdown Panel and the Monte Carlo calculator.
← All free NinjaTrader 8 strategies · Risk & disclosures