VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Strategy generation

Automated trading strategies: 3 futures examples worth testing

Automated trading strategies worth testing on futures are complete written rules a computer can run alone: a breakout, a mean-reversion and a trend-following rule, each with an exact entry, exit and size. Grade them with a backtest that includes costs, validate in a fixed order, and only then export them to your platform.

By · Published · updated · Editorial policy

Contents
  1. What is an automated trading strategy?
  2. Which three strategy types are worth testing on futures?
  3. Do automated trading strategies work? What one NQ backtest shows
  4. Which strategy types are easiest to automate?
  5. How do you test a strategy before automating it?
  6. How do you move a tested strategy to your platform?
  7. Frequently asked questions
  8. References

What is an automated trading strategy?

Automated trading strategies worth testing on futures are rules a computer can run alone: a breakout rule, a mean-reversion rule and a trend-following rule, each with an exact entry, exit and position size. A backtest with commission and slippage grades them first, and only a rule that passes a fixed set of checks is allowed to send live orders.

An automated trading strategy is a complete set of written rules that a computer executes on new price data without a human decision inside the loop. Think of a thermostat: it reads one number, compares it with a setting, and switches the heating on or off. Nobody decides each time. A trading rule works the same way. When the bar closes, the program checks the condition, sends the order at the next bar, and watches the exit. If any step needs a person to look at the chart and judge, the strategy is not automated yet, and more important, a backtest cannot grade it, because the backtest cannot copy the judgment. The wider picture of what algo trading is and why most rules lose explains where this loop sits in the whole process.

An automated strategy is a closed loop: the bar closes, the rule checks its condition, the order is sent at the next bar, the exit rule watches the position, and no person makes a decision anywhere in the loop No human inside the loop Example: close above 20-bar high Bar closes Rule checks Order sent Exit watches No human No step needs a person. So: state every rule exactly.
An automated strategy is a closed loop from bar data to orders. There is no step inside it where a person decides.

This gives a simple test for any strategy idea: can you write the entry, the exit and the size each in one sentence that two different programmers would code the same way? "Buy when the close is above the highest high of the last 20 days" passes. "Buy when the trend looks strong" does not. If you cannot state a strategy this exactly, do not automate it: you cannot test it, and you will not know when it has stopped working.

Which three strategy types are worth testing on futures?

Breakout, mean reversion and trend following are the three families that survive automation best, because each has a one-sentence entry, a one-sentence exit and a known market condition in which it fails. Knowing where a rule fails matters as much as knowing where it works: it tells you what a bad month should look like, so you can tell normal losses from a broken strategy.

A breakout strategy is a rule that enters when price leaves a range it has stayed inside for a set number of bars. Mean reversion is a rule that enters when price has moved unusually far from its recent average and exits when price returns to that average. Trend following is a rule that holds a position in the direction of a long-term average and reverses or exits when that average turns. The table and figure compare them on the four points that decide how they behave when automated.

BreakoutMean reversionTrend following
Entry triggerPrice leaves a rangePrice stretches far from an averageLong-term average turns
ExitOpposite break or time limitReturn to the averageAverage turns back
Typical holding timeHours to daysHoursWeeks
Where it failsQuiet sideways marketStrong one-way trendChoppy market
Trades per year on daily barsDozensDozensA handful
Each strategy type has a market where it works and one where it fails: breakout works in a trend and fails in a quiet range, mean reversion works in a range and fails in a strong trend, trend following works in a trend and fails in a choppy market Each type has a weak market Which market suits it, which breaks it Range Trend Choppy Breakout Fails Works – Mean reversion Works Fails – Trend following – Works Fails Losses in its weak market are normal. So: check the market before you quit.
The three families differ in trigger, exit, holding time and failure condition. The failure column tells you what a normal bad period looks like.

Here is one exact version of each, written so a backtest can grade it. These are generic textbook rules, not the only form of each family.

  1. Breakout (channel): buy at the next bar when the close is above the highest high of the previous 20 bars; exit when the close is below the lowest low of the previous 10 bars. Mirror the rule for short trades. One contract.
  2. Mean reversion (band): buy at the next bar when the close is more than two standard deviations below its 20-bar average; exit when the close crosses back above that average. Mirror for shorts. One contract.
  3. Trend following (two averages): be long while the 50-bar average is above the 200-bar average and short while it is below; the exit is the next cross. One contract.

The holding-time row explains why costs hit these families so differently. A mean-reversion rule that holds for hours on intraday bars is a form of day trading, and the per-trade edge is small, so costs decide the result; the article on day trading explained, with costs tested works through that arithmetic. A trend rule on daily bars holds for weeks and pays costs rarely, but produces few trades, which makes its backtest hard to judge. For a wider menu of rule types with their backtest settings, see the five types of futures algo trading strategies.

Do automated trading strategies work? What one NQ backtest shows

A backtest tells you what a rule did on past prices after costs, not what it will earn, and the run shown here is one kept candidate out of about a thousand tried, so its numbers are flattered by that selection and must be read as a starting point for validation. "Do they work" has no yes-or-no answer. What you can do is measure what a rule did after costs, then test how much of that result survives data the rule never saw.

The run below comes from the research engine of AlphaPrime (Valynox). It tested NQ (E-mini Nasdaq-100 futures) on daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with $20 commission and $10 slippage charged on every trade. The rule is a stand-in built from a standard indicator, not one of the three examples above: a CCI rule serves as the only entry and exit, with no stop, no target and no filter. The search tried about a thousand parameter candidates and kept this one for its return against its drawdown. Picking the kept candidate after the fact flatters it: the best of a thousand tries always looks better than the rule deserves, which is the effect Bailey, Borwein, López de Prado and Zhu (2014) describe. Neither the CCI nor the rule "earned" this money, and no reader should expect it.

Source: AlphaPrime product engine (CPU), run 2026-10-31. NQ daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $10 slippage per trade.

NumberResult
Net profit (closed trades)$192,105
Max drawdown$71,325
Trades168
Win rate58.93%
Profit factor1.423
Average trade$1,143.48
Time in market56.02%

Read the drawdown before the profit. Maximum drawdown is the largest fall in account equity from a peak to the following low before a new peak. Here $71,325 sits against $192,105 of net profit, and the drawdown is the number you would have lived through, with no way of knowing at the time whether the curve would recover. Profit factor is gross profit divided by gross loss; 1.423 means winners brought in about 1.4 dollars for every dollar lost. The 168 trades over about six and a half years are a modest sample: per-trade averages from a sample this size move a lot when a few trades change. The $10 slippage equals two ticks on NQ, where one tick of 0.25 index points is worth $5.00 and one full point is worth $20 (CME Group contract specifications). Exchanges change contract values from time to time, so check the exchange's contract page, or the futures contract calculator that lists tick size and tick value, before setting costs in your own run.

Look at the shape of the equity curve rather than its end point: how deep the drawdown periods are, how long they last, and whether the slope after the marked out-of-sample line resembles the slope before it.
Look at the shape of the equity curve rather than its end point: how deep the drawdown periods are, how long they last, and whether the slope after the marked out-of-sample line resembles the slope before it. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest
Read the summary as pairs: net profit against maximum drawdown, and profit factor against the trade count. A result from few trades deserves less trust than the same result from many.
Read the summary as pairs: net profit against maximum drawdown, and profit factor against the trade count. A result from few trades deserves less trust than the same result from many. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

Which strategy types are easiest to automate?

The best candidates for automation decide on the bar close, use few parameters, produce enough trades to measure, and keep the average trade several times the round-trip cost; strategies that need a reading of the chart or a decision inside the bar are the hardest to automate honestly. "Honestly" is the key word. Almost anything can be coded. The question is whether the code behaves in live trading the way it behaved in the backtest.

Five traits compared: easy-to-automate rules act at the bar close, use 2 to 4 parameters, have hundreds of trades, a wide margin over costs and an exit by rule; hard ones act inside the bar, use 8 or more parameters, have under 30 trades, a thin cost margin and an exit by feel Easy vs hard to automate Five traits, side by side Easy to automate Hard to automate Acts at bar close 2–4 parameters Hundreds of trades Wide cost margin Exit by rule Acts mid-bar 8+ parameters Under 30 trades Thin cost margin Exit by feel
Five traits separate a strategy that will behave live as it did in the test from one that will not.

Each trait has a reason behind it.

  • Decision at bar close. The backtest knows the close only when the bar has ended. A rule that acts on the close and fills at the next bar open uses prices it could have traded at. A rule that acts "when price touches a level" inside the bar has to guess the order of events inside that bar, and the guess is usually optimistic.
  • Two to four parameters. Every parameter is a dial the search can turn to fit noise. The 168 trades in the NQ run above can support a couple of parameters; they cannot support eight.
  • A few hundred trades. An average built from 30 trades can move a long way when two trades change. The trend rule on daily bars is the hardest of the three families here, because it produces so few trades; walk-forward windows, covered in the next section, help by producing more out-of-sample trades from the same history.
  • Average trade several times the round-trip cost. Slippage is the gap between the price your backtest assumed and the price the market actually gave you. If the average trade only just covers costs, a small rise in slippage turns the strategy negative.
  • Exit defined by rule. An exit "when it looks wrong" cannot be tested and cannot be coded. Every exit must be a condition on prices, time or the position itself.

Hypothetical example

Two intraday rules on the same contract both show a gross average trade of $45. Rule A trades once a day; Rule B trades six times a day. Commission and fees are $5 per round trip and slippage is one tick each side, $10 in total, so the round trip costs $15. Both rules keep $30 per trade after costs, which is twice the cost. Now double the slippage to $20 per round trip: the cost rises to $25 and each rule keeps $20 per trade. Both still pass, but with little room, and Rule B pays that cost six times as often, so a further increase in slippage hurts it first. A rule with a gross average trade of $20 would fail at the first step.

The same five traits are the checklist for building an intraday rule from scratch; the step-by-step route in how to build and test a day trading algorithm applies them to a rule that opens and closes positions within the session.

How do you test a strategy before automating it?

Run the checks in a fixed order written down before you look at any result: costs and next-bar execution in the first run, an in-sample and out-of-sample split, walk-forward windows, a robustness pass, and one final untouched block, and only a strategy that passes all of them moves to automation. The order matters because the cheap checks remove most candidates early, and the expensive final block is then spent on very few.

  1. Backtest with commission, slippage and next-bar execution from the first run. A search that ranks candidates without costs favours rules with many tiny trades, and adding costs afterwards removes most of the finalists.
  2. Split the history in time. Tune on the earlier 70 to 80 percent (in-sample) and run the rule unchanged on the later part (out-of-sample). Decide in advance how much of the in-sample average trade must survive.
  3. Run walk-forward windows. Walk-forward analysis is a test that tunes settings on one window, runs them unchanged on the next window, moves forward and repeats, so that the joined out-of-sample segments form one result built only from settings chosen before their data existed. Pardo (2008) describes the method and its window choices in detail, and the article on walk-forward analysis as the one backtest number you could have traded covers how to read the joined curve.
  4. Run a robustness pass. Double the slippage, run the neighbouring parameter settings, remove the five largest winners. A rule that only works at one setting, or only because of a few trades, has described noise.
  5. Test one final untouched block exactly once. Keep the most recent months of data out of every research run. A second look turns this block into tuning data.
  6. Automate. Only a rule that has passed every step reaches this box.
Six checks in a fixed order: backtest with costs, in-sample and out-of-sample split, walk-forward windows, robustness pass, one final untouched block, then automate; a failure at any of the first five steps sends the rule to reject Six checks, in this order Fail one and the rule goes back 1 2 3 4 5 6 Backtest with costs In-sample / OOS split Walk-forward windows Robustness pass Final untouched block Automate Reject
The fixed order of checks between a backtest and automation. A failure at any step sends the strategy back, never forward.

For the NQ run above, this means the box in the previous section is the output of step 1 for one candidate. Steps 2 to 5 still have to happen, and most kept candidates from a large search fail somewhere between steps 2 and 4. That is not a disappointment; it is the process doing its job. The alternative is to find out the same thing with a live account.

How do you move a tested strategy to your platform?

Export the exact rules as source code for your platform, load them there with the same session, bar size and costs, compare the platform's trade list against the research report trade by trade, paper trade through at least one contract roll, and only then switch to live orders. Each step is a gate: the strategy moves forward only when the step is explained.

  1. Export the source code for the chosen platform. The code must be the rule you validated, with the same parameter values, not a rewrite from memory.
  2. Load it on the platform's chart with the same settings. Same contract, same session hours, same bar size, same commission and slippage, same start date. A different session alone changes the bars and therefore every signal.
  3. Compare the trade lists. Line up the platform's trades with the research report's trades by date and direction. Small differences are expected, from data vendors, roll dates or rounding; the task is to explain each difference, not to remove every one. An unexplained difference points to a setting that does not match.
  4. Paper trade through at least one contract roll. The roll is where most live automation problems appear: the position must move to the new contract, and the strategy's indicators must read the new series correctly.
  5. Switch to live orders with the planned contract count. The count comes from the validated drawdown and your account size, decided before the first live order, not raised after a good week.
Two gates before live orders: after export and setup, the trade-list comparison and the paper trade through a contract roll each must pass, and any unexplained gap sends the strategy back to its settings instead of forward to live trading Two gates before live orders A miss sends it back, not forward Gate 1 Gate 2 Setup Compare Paper roll Live Unexplained gap? Back to setup Explain every gap before going live. So: never skip the roll test.
From exported code to live orders, with the trade-list comparison and the paper-trading period as gates.

Step 1 is where the research tool meets the trading platform. Once a candidate has passed the checks in the previous section, AlphaPrime writes its rules out as source code for MultiCharts (PowerLanguage), TradingView (Pine Script v6), TradeStation (EasyLanguage), NinjaTrader (NinjaScript), MetaTrader 4 (MQL4) and MetaTrader 5 (MQL5), so that the code you load in step 2 is the rule that was tested and not a second version typed by hand; the platform export page lists the supported platforms and what each export contains. Whatever tool produced the code, step 3 is yours to do. Load the exported strategy, run it over the same period as your research report, and count the trades. If the count differs, find the setting that explains the difference before you paper trade a single bar.

Frequently asked questions

What are the best automated trading strategies for futures?

The best candidates are the ones you can state as exact rules and grade with a backtest that includes costs: breakout, mean reversion and trend following are the three families that do this most easily. "Best" is not a fixed list of rules, because a rule that passes validation on one market and bar size can fail on another. Judge each rule by what survives out-of-sample and walk-forward testing after costs, not by the headline of a single backtest.

Can an automated strategy run without me watching it?

The rules run without judgment, but the setup still needs attention at known points: contract rolls, exchange holidays with early closes, data feed interruptions and margin changes. Paper trading through at least one roll shows you what the strategy does at these points before real money is involved. Plan a short daily check of positions and fills rather than watching every bar.

How many trades does a backtest need before I automate the strategy?

Enough that the average trade cannot move much when a few trades change. Many systematic traders aim for a few hundred trades across the whole test and treat fewer than about 30 as a hint rather than a result. The uncertainty of an average shrinks with the square root of the trade count, so four times as many trades halve it. If a single history holds too few trades, walk-forward windows produce more out-of-sample trades from the same data.

Can I automate a tested strategy on MultiCharts, TradingView or NinjaTrader?

Yes, provided the rule can be written as source code in the platform's language and run on the platform's own data. The usual route is to export the exact rules, load them with the same session, bar size and costs, and compare the trade list with the research report before paper trading. AlphaPrime exports strategy source code to MultiCharts, TradingView, TradeStation, NinjaTrader, MetaTrader 4 and MetaTrader 5.

References

  • 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.
  • Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
  • CME Group. E-mini Nasdaq-100 Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html