Trading bot for NQ futures: how to build, test and run one
A trading bot for NQ futures is a written rule set that trades Nasdaq-100 futures without a human decision. Build it in six steps: write the rule, set NQ costs and sessions, backtest, validate on unseen data, export to your platform, then compare live fills with the backtest. The number that decides it is the average trade after costs.
By Soren Huang · Published · updated · Editorial policy
Contents
- How do you build and test a trading bot for NQ futures?
- Can a trading bot make money on NQ futures?
- What do NQ tick value, margin and volatility mean for a bot?
- Should a small account run the bot on MNQ instead of NQ?
- What rules work best for an NQ bot?
- How should you backtest and validate an NQ bot?
- What should you monitor once the bot is live?
- Frequently asked questions
- References
How do you build and test a trading bot for NQ futures?
A trading bot for NQ futures is a written rule set that enters and exits Nasdaq-100 futures trades without a human decision. You build it in six steps: write the rule, set NQ costs and sessions, backtest, validate on data the rule never saw, export the code to your platform, then compare live fills with the backtest every week.
The six steps run in one direction. A result from a later step never sends you back to change a setting in an earlier step. If you want to change the rule after seeing a live or out-of-sample result, you start again at step one with a new candidate, because a tweaked rule has seen data it should not have seen. The same order applies to any intraday system, and the route for building and testing a day trading algorithm explains each step in general terms. This article applies them to NQ.
- Write the rule in full. Entry, exit, stop, position size and the session in which the bot may trade. Every value is written in index points, which the next sections convert to dollars.
- Set NQ costs and session. Commission per contract, slippage in ticks and the hours the bot trades. These settings belong in the first backtest, not the last.
- Backtest on the full history with costs included. Read the trade count and the average trade after costs before you read net profit.
- Validate on unseen data. Split the history by date, grade the rule on the later part unchanged, then roll the test forward in windows.
- Export to your platform. AlphaPrime (Valynox) writes the finished rule out as source code for the trading platforms listed on its platform export page, so the bot that runs live is the same rule that passed the tests, not a hand-typed copy.
- Monitor live fills against the backtest. Slippage, trade count and drawdown, compared each week with the values the backtest assumed.
Can a trading bot make money on NQ futures?
A bot can only keep what is left after commission and slippage, so the one number that decides it is the average trade after costs compared with the round-trip cost. The round-trip cost is everything you pay to open and close one position: commission and exchange fees on both sides, plus slippage on both sides. Slippage is the difference between the price the backtest assumed and the price you actually get. Most candidate rules fail this comparison, not the gross backtest.
NQ is a liquid market during US cash hours, so one tick of slippage per side on a market order is a reasonable starting estimate for a stop or market entry. One tick on NQ is $5 (CME Group contract specifications), so a round trip with one tick each side costs $10 in slippage before any commission. That sounds small until the rule's average move per trade is also small.
Hypothetical example
A rule shows a gross average trade of $35 on one NQ contract. Commission and fees are $5 per round trip and slippage is one tick each side, $10 in total. The net average trade is $35 − $5 − $10 = $20. Now double the slippage to two ticks each side, which is normal around the open or a news release: the net average trade falls to $35 − $5 − $20 = $10. A rule with a gross average trade of $35 lives or dies on execution quality. A rule with a gross average trade of $150 barely notices the same change.
A practical rule many systematic traders use: the gross average trade should be at least three to five times the round-trip cost. The reasoning is simple. Your cost estimate is uncertain, and a rule that survives only at the lowest estimate will not survive the first volatile week. Trading costs in backtests shows how to set commission and slippage so the ranking of candidates already reflects what you could trade.
What do NQ tick value, margin and volatility mean for a bot?
NQ moves $20 per index point and $5 per 0.25-point tick, so every stop, target and position size in the bot must be written in points and converted to dollars before you can judge the risk. The contract size is $20 times the Nasdaq-100 index and the minimum price move is 0.25 index points, both set in the CME Group contract specifications. The free futures contract calculator converts points and ticks to dollars for NQ and other contracts.
A tick is the smallest price change the exchange allows. On NQ four ticks make one index point. A stop written as "50 points" is therefore 200 ticks, and the conversion to dollars is fixed by the contract, not by your broker.
Hypothetical example
The bot uses a 50-point stop on one NQ contract. 50 points × $20 = $1,000 at risk per trade before slippage. If the rule's typical winning move is 100 points, the win is $2,000. A trader with a $30,000 account who wants to risk 2 percent per trade ($600) cannot run this rule on one NQ contract; the smallest stop the account allows is 30 points, which may be too tight for the way NQ moves.
Margin is the deposit the exchange and your broker require to hold one contract. The exchange sets the base figure and changes it when volatility changes, and brokers may add their own intraday requirement. Because the value moves, do not hard-code it: read the current figure on the exchange's contract page before you size the bot, and reread it after a volatile week. The same contract page lists the trading hours, which also change from time to time.
Volatility matters because NQ has a wide daily range relative to other index futures. A stop that is comfortable on ES in points is often too tight on NQ. Measure the range on your own bar data with a volatility indicator rather than copying a number, and write the stop as a multiple of that measure. The guide to NQ and MNQ futures specs, sessions and backtest costs goes through the session boundaries that affect where the range is measured.
Should a small account run the bot on MNQ instead of NQ?
MNQ is one tenth of NQ, $2 per index point and $0.50 per tick, which lets a small account keep risk per trade small, but commission per contract does not shrink by ten, so the average trade after costs must be checked again on MNQ before the same rule is trusted. MNQ is the Micro E-mini Nasdaq-100 futures contract, listed by CME Group alongside NQ and tracking the same index.
The price moves are the same on both contracts, so a rule that triggers on NQ triggers at the same bar on MNQ. What changes is the dollar size of every move and the share of that move that costs take.
| Item | NQ | MNQ |
|---|---|---|
| Point value | $20 | $2 |
| Tick value (0.25 point) | $5 | $0.50 |
| Dollar risk of a 40-point stop | $800 | $80 |
| Slippage of two ticks | $10 | $1 |
| Commission per contract | Set by broker | Set by broker; usually not one tenth of NQ |
Hypothetical example
The rule from the earlier example has a gross average trade of $35 on NQ, so $3.50 on MNQ. Slippage of two ticks is $1 on MNQ. If the broker charges $1.50 per round trip on MNQ instead of $5 on NQ, the net average trade is $3.50 − $1.50 − $1 = $1.00. Costs took 43 percent of the gross move on MNQ against 43 percent on NQ only if commission had also fallen to $0.50; it did not. The rule still passes, but with less room, and the trader should know that before the first live contract.
The practical answer for a small account is yes, run MNQ, and rerun the backtest with MNQ commission and tick value entered. A rule that passes on NQ and fails on MNQ is telling you that its edge per trade was close to the cost line all along. Ten MNQ contracts give the same exposure as one NQ contract, so MNQ also lets the bot step position size up gradually as the account grows.
What rules work best for an NQ bot?
Rules that fit NQ respect its session structure and wide daily range: opening-range breakouts, trend-following with volatility-based stops and a time exit, while rules that depend on tiny moves lose to costs first. The session structure matters because NQ trades almost around the clock on CME Globex, with a daily halt from 4:00 p.m. to 5:00 p.m. Central Time, but most of its volume and range arrive during US cash equity hours, 8:30 a.m. to 3:00 p.m. Central Time. A bot that trades the quiet overnight hours with the same stop as the cash session is running two different strategies under one name.
An opening-range breakout is a rule that waits for the first minutes of the cash session, records the high and low of that range, and enters when price leaves it. It fits NQ because the open is where the range is widest, so the move per trade is large relative to two ticks of slippage. Trend-following with an ATR stop fits for the same reason: the Average True Range measures how far NQ has been moving per bar, so the stop widens on volatile days and tightens on quiet ones instead of being hit by noise.
| Rule type | Typical move per trade (points) | Trades per day | Cost share of the move | Fit for an NQ bot |
|---|---|---|---|---|
| Opening-range breakout | Tens of points | 0 to 2 | Low | Good |
| Trend-following with ATR stop | Tens to hundreds of points | Under 1 | Low | Good |
| Mean reversion of small moves | A few points | Several | Medium to high | Check after costs |
| Scalping a few ticks | Under 2 points | Many | High | Poor |
A time exit, which closes any open position at a fixed clock time such as a few minutes before the cash close, is worth adding to most intraday NQ rules. It keeps the bot out of the overnight session it was not tested on and makes the trade count predictable, which helps the live monitoring described later.
How should you backtest and validate an NQ bot?
Set the session, costs and next-bar execution before the first run, then grade the rule on data it never saw with an in-sample/out-of-sample split and walk-forward windows. Next-bar execution means a signal computed on the close of one bar is filled at the open of the next bar, because a bot cannot trade a close it has only just seen. The five settings that most often go wrong on index futures are listed in ES and NQ futures backtesting: five things to set first.
Think of validation as a ladder. Each rung grades the rule on data the previous rung did not use, and a rule that fails one rung stops there.
- Full-history backtest with costs. Check the trade count and the average trade against the round-trip cost.
- In-sample tuning block. Choose settings on the first 70 to 80 percent of the history only.
- Out-of-sample block. Run the chosen settings unchanged on the remaining history and compare the average trade with the in-sample figure.
- Walk-forward windows. Walk-forward analysis is a test that tunes on one window, trades the next window unchanged, moves forward and repeats, so the joined out-of-sample segments show what you could actually have traded.
Why the ladder matters becomes clear when a search tries many candidates. Bailey et al. (2014) show that the best backtest out of many tries is inflated by selection alone, before any real edge is counted. The run below shows what a kept candidate's summary looks like. It is an ES test on daily bars, not NQ, and it uses a stand-in rule: a Candlesticks rule as the only entry and exit, with no stop, no target and no filter, not an NQ bot rule. The search tried 1,024 candidates and kept this one for how its return compared with its drawdown. Picking the kept one after the fact flatters it, so the numbers describe that one candidate on that history and nothing more.
Source: AlphaPrime product engine (CPU), run 2026-10-31. ES daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $25 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $129,630 |
| Max drawdown | $59,010 |
| Trades | 56 |
| Win rate | 57.14% |
| Profit factor | 2.022 |
| Average trade | $2,314.82 |
| Time in market | 93.48% |

Three readings from this box show how to read any report. First, 56 trades over six and a half years is a small sample, so the average trade of $2,314.82 can move a long way if a handful of trades change. Second, the average trade is large against the $45 of commission and slippage per trade, which is the cost check from the second section passing with room to spare. Third, time in market of 93.48 percent means the rule was almost always holding a position, so much of its result is the market's own direction over the period, not timing. None of these say that the rule earned that money or that a reader can expect it; they say which fields to read and in what order. In AlphaPrime the in-sample, out-of-sample and walk-forward rungs run as strategy validation with thresholds you set before the search, and a candidate that fails one rung is not sent up to the next.
What should you monitor once the bot is live?
Compare three live numbers with the backtest every week: slippage per trade, trades per week and current drawdown against the backtest maximum, and stop the bot when a limit you wrote before going live is crossed. The limit is written in advance because a trader looking at a live loss will always find a reason to wait one more week.
| Reading | Backtest assumption | Live reading | Stop rule written in advance |
|---|---|---|---|
| Slippage per trade | Two ticks per round trip | Fill price minus signal price, averaged over the week's trades | Average above double the assumption for two weeks |
| Trades per week | Count from the backtest report divided by its weeks | Trades the bot actually placed | Far above or below the backtest count: a rule firing twice as often is not the tested rule |
| Current drawdown | Backtest maximum drawdown | Peak equity minus current equity | Past 1.5 times the backtest maximum |
Slippage is the easiest to measure and the first to drift. Your platform's fill log gives the fill price; the bot's signal price is the next bar's open in a next-bar backtest. The difference, in ticks, averaged over the week, is your live slippage. If it sits well above two ticks, the backtest must be rerun with the measured value before you decide anything else. The trade count catches a different fault: a session setting that differs between the research data and the live chart, so the bot trades hours it was never tested on. The drawdown limit of 1.5 times the backtest maximum is a common choice because a live drawdown that already exceeds the worst the history produced is evidence that the history was too kind.
Before the first live contract, run through the six checks before going live with an algo, then do one thing this week: take your current NQ candidate, note its gross average trade from the report, and divide it by your round-trip cost with two ticks of slippage. If the answer is below three, the next test to run is the same rule with doubled slippage, before any further work on entries.
Frequently asked questions
Can a trading bot make money on NQ futures?
A bot keeps only what is left after commission and slippage, so the question is whether the rule's average trade after costs stays positive on data it was not tuned on. On NQ one tick is $5, so a round trip with one tick of slippage each side costs $10 before commission. A rule whose gross average trade is several times that cost, and whose out-of-sample average trade is still positive, has passed the checks that most candidates fail. No backtest turns that into a forecast.
Can I run a bot on MNQ instead of NQ?
Yes. MNQ tracks the same index at one tenth of the size, $2 per point and $0.50 per tick, so the same signals fire on the same bars. Rerun the backtest with MNQ tick value and MNQ commission entered, because commission per contract is usually not one tenth of the NQ figure and takes a larger share of each move. Ten MNQ contracts equal the exposure of one NQ contract, which lets a small account scale in steps.
How much margin does an NQ bot need?
The exchange sets the margin per contract and changes it when volatility changes, and your broker may require more for overnight positions or less for intraday positions. Read the current figure on the exchange's contract page and your broker's margin table before sizing the bot. Size the account to the backtest maximum drawdown plus margin, not to margin alone, because the drawdown is what the account has to absorb while the position is held.
What rules work best for an NQ bot?
Rules with a large move per trade relative to costs: opening-range breakouts at the cash open, and trend-following with an ATR-based stop and a time exit before the close. Scalping rules that aim for a few ticks hand most of each move to commission and slippage. Whatever the rule, restrict it to the session you tested, because NQ's overnight hours behave differently from the cash session.
References
- CME Group. E-mini Nasdaq-100 Futures contract specifications (contract size $20 × index, minimum tick 0.25 index points = $5.00). cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html
- CME Group. Micro E-mini Nasdaq-100 Index Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/micro-e-mini-nasdaq-100.contractSpecs.html
- Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.

