VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Strategy generation

What Is a Program Order and How Do You Place One?

A program order is an order a computer program generates and sends automatically by rules written in advance; program trading is the whole process, and the program order is only the last order in it. You do not have to write the code yourself, but you need to understand the rules and backtest them with costs before the first order goes out.

By · Published · updated · Editorial policy

Contents
  1. What is a program order?
  2. How do you place a program order? The sequence from opening an account to the first order
  3. Do you have to write code for a program order?
  4. How does a program order differ from a conditional order?
  5. What order types and risk controls do program orders commonly use?
  6. How do you backtest a rule before placing a program order?
  7. Frequently asked questions
  8. References

What is a program order?

A program order is an order that a computer program generates automatically from preset rules and sends to the futures broker. You write the rules, start the program and reconcile afterward; when to enter, when to exit and how many contracts are all decided by the program. Program trading is the whole process. A program order is only the last order that chain sends out.

Take a program order apart and you find three separate layers. Strategy rules are entry and exit conditions you can state in plain words, for example “go long when the close is above the 20-day average and close out when it falls below”. The trading program is the software that turns those rules into steps a computer can run and re-evaluates them at the end of every bar. The order channel is the API or connection module your futures broker provides, which the program uses to send orders to the futures exchange. Keeping the three layers apart pays off in practice: when you lose money, it lets you tell whether the rule was bad all along, the program was written wrong, or the connection dropped. Common rule types such as trend following and mean reversion each backtest differently; Four common types of quant trading strategy and how their backtests differ lays them out.

Program trading is a chain of three layers: rules, program and broker connection. A program order is only the last link in that chain, the one order the program sends to the broker. The order is the last step Three layers, one order at the end Program trading Rules Program Broker Program order Three layers, three failure points. So fix the layer that failed.
Program trading is the whole chain; a program order is just the one order sent between the last two boxes.

One claim runs through this article: the value of a program order is not that it is automatic, but that the rule can be tested beforehand and reconciled afterward. A rule that has not been backtested, sent by program, only executes its mistakes faster and more punctually.

How do you place a program order? The sequence from opening an account to the first order

In Taiwan the sequence for placing a program order is fixed: open an account and enable program trading permission, install software that can take orders, load the strategy, run on a paper account for a while and reconcile, and only then switch to live trading. The most common result of doing the steps out of sequence is finding out in live trading that the number of contracts or the symbol code is set wrong.

  1. Open an account with a futures broker and enable program trading permission. Most futures brokers treat the API or program trading as a separate service, which needs an extra application and signed documents. Ask everything at account opening: which trading software is supported, whether the API has a fee, and how to apply for a paper account.
  2. Install order-taking trading software and connect. MultiCharts writes strategies in PowerLanguage and connects to the account through a connection module the futures broker provides. Touchance is order software that several Taiwan futures brokers provide to their customers, and it connects directly to that broker's account. Its features, fees and whether it can run strategies are covered neutrally in What is Touchance and which futures brokers support it. There is only one test for choosing software: it can connect to the futures broker where you opened your account.
  3. Load the strategy and set the symbol, contracts and session. The symbol code, contract month, contracts per entry and whether the program runs the night session are all fixed in this step, not adjusted at the open.
  4. Run on a paper account for at least several weeks and reconcile. Reconciliation means comparing, one by one, the entries and exits the program recorded against the fill reports the futures broker sends back, and checking that price, contracts and time agree. This step is the gate before live trading.
  5. Switch to the live account, with a daily maximum loss shutdown already set. Use the smallest size on the first day and repeat the reconciliation from step 4.
Five steps from opening an account to the first live program order: open an account, install software, load a strategy, then paper trade and reconcile as a gate, and only then trade live with one contract Paper trade first, then go live Five steps, in this order 1 Open account 2 Install software 3 Load strategy 4 Paper trade and reconcile Gate 5 Live trading, 1 contract If reconciliation fails, don't go live. So confirm every fill first.
Five steps from opening an account to the first live program order; the paper-trading reconciliation in step 4 is the gate before live trading.

If you are starting with TAIEX futures, Program trading for TAIEX futures: zero to first strategy, no coding spells out each step above as Taiwan futures brokers actually handle it. If you want a practice plan with a timetable, First algo trading strategy: a 30-day route for beginners lays out account opening, backtesting, paper trading and live trading as a month-long schedule.

Do you have to write code for a program order?

You do not have to write code yourself, but you must understand the rules the program runs. There are three routes to a program order: write it yourself, use a strategy someone else wrote, or first generate and backtest rules without writing code and then export them as source code the platform can read. The three routes differ in how much code you write and how much you can see, change and judge.

ItemWrite the code yourselfUse a ready-made strategyGenerate rules without coding, then export
Do you need to code?YesNoNo
Can you see the full rules?YesPartly (depends on whether the author publishes them)Yes
Can you change the parameters?YesPartlyYes
Can you diagnose problems yourself?YesNo or partlyYes, if you have read the rules
Comparison of three routes to a program order: writing it yourself means coding and seeing the rules; a ready-made strategy means no coding but only partly seeing the rules; generate-then-export means no coding and seeing the rules You need rules, not code Three paths to a program order Code? Rules? Write your own Yes Yes Ready-made strategy No Partly Generate, then export No Yes Code is optional; reading rules is not. So hand-check three trades.
Three routes to a program order: they differ in how much code you write and how far you can see and change the rules.

Understanding the rules does not mean knowing how to code. It means being able to say in one sentence why each order was sent. The minimum bar is this: once you have a strategy, pick any three trades from the backtest yourself and, against the bars, explain which rule each entry and exit meets. If you cannot, you also cannot tell whether a fault lies in the rule, the program or the connection. On the third route, AlphaPrime (Valynox) exports the rules it generated and backtested as readable strategy source code, which you then load into a trading platform to send orders; for the platforms it supports, see trading platforms supported by strategy source code export. Once you have the source code, you still need to do the “pick three trades and check them against the rules” step from the previous paragraph yourself.

How does a program order differ from a conditional order?

Conditional orders and program orders are both automatic order placement. The differences are who evaluates, how many times, and who sends the order if the connection drops. A conditional order is a trigger condition you set by hand in the futures broker's order software, for example “sell 1 contract when the traded price reaches a given level”; whoever is watching quotes sends one order for you when the condition is met. A program order is your own program continuously reading quotes and re-evaluating the rule on every bar or every trade, deciding entry, adding and exit itself, with entry and exit linked to each other.

ItemConditional orderProgram order
Who checks the conditionFutures broker's server (cloud conditional order) or your order softwareYour own program
How many checksTriggers once, then doneRe-checked on every bar or every trade
Entry and exit linked?No, one conditional order maps to one actionYes, the exit rule knows a position is open
If the computer disconnectsIf the futures broker's server is watching, it still sends the orderThe program stops; after reconnecting, reconcile before continuing
Suited forA single stop loss, a single entry at a priceA whole strategy: entry, adding, exit, contracts
Conditional order vs program order: the broker checks a conditional order once and it can still trigger after your computer is shut off; your program checks a program order on every bar and stops when the computer shuts off Automated, but not the same Conditional order vs program order Conditional Program Checked by Broker Your program Frequency Once Every bar PC shut off Still fires Stops Program runs; the server backs it up. So add a server-side stop loss.
Conditional orders and program orders are both automatic order placement, but who evaluates, how many times, and what happens on a disconnect are completely different.

Look closely at the disconnection row. A conditional order held on the futures broker's server still triggers when your computer is off; a program order stops along with your computer. This matters especially in the night session, because the program has to keep running until the early hours while you are asleep. The night session has thinner liquidity and larger slippage; After-hours trading explained: hours, liquidity, backtest pitfalls covers what that does to program-order fills and to backtests. A common safe practice is to use both: the program order runs the strategy, and a conditional order on the broker's server serves as a protective stop loss, which the program cancels as soon as the position is closed.

What order types and risk controls do program orders commonly use?

The four order types a program order usually sends are market, limit, stop and stop-limit, and each trades off between “the order always fills” and “the price is certain”. Risk control needs at least four items, written into the program's decision loop rather than relying on someone watching the screen. Start with order types. A market order asks to fill immediately at whatever price can be filled right now. A limit order names a price and fills only at that price or better. A stop order turns into a market order once the traded price touches the set level. A stop-limit order turns into a limit order after it triggers, which gives price certainty at the cost of possibly not filling on a gap.

Order typeAlways fills?Price certain?Common use in program orders
MarketYesNoEnter or exit immediately on a signal
LimitNoYesRest an order at a fixed price and wait for a fill
StopYes, once triggeredNoStop loss exit, breakout entry
Stop-limitNoYesAvoid a wild fill price on a gap
Four order types, each picking one side: market and stop orders favor getting filled over the price; limit and stop-limit orders favor the price over getting filled Fill or price: pick one Four order types a program sends Fills? Price set? Market Yes No Limit No Yes Stop Yes No Stop-limit No Yes Each order type picks one side. So backtest the orders you send.
The four order types each pick a side between “the order always fills” and “the price is certain”; the program has to choose the right one for each action.

Backtest assumptions must match the orders the program actually sends. If a backtest assumes a limit order fills whenever price touches it, in live trading it often queues and never gets to the front. If a backtest fills at the close, a live market order takes slippage. These two gaps are what the weeks on the paper account are meant to surface through reconciliation.

There are four risk controls, and leaving out any one means the job is not done:

  1. Daily maximum loss shutdown. When the day's realized plus unrealized loss exceeds a preset amount, the program closes out and stops sending orders until it is restarted the next day.
  2. Maximum contracts cap. No matter how many entry signals the rule produces in a row, total position cannot exceed the cap. This one guards against duplicate orders when the program logic is wrong.
  3. Reconnection after a disconnect. When the program detects that the connection has dropped, it reconnects automatically and sends no new orders until the reconnection succeeds.
  4. Position reconciliation. After every order and after every reconnection, compare the position the program thinks it holds with the position the futures broker reports; if they disagree, shut down and let a person handle it.
Between the strategy signal and sending an order, the program itself runs four checks: daily loss limit, contract cap, connection OK, position match; if any one fails, no order is sent Checks live in the loop Every order passes four checks Signal Daily loss limit Contract cap Connection OK Position match Send Any check fails: no order sent. So code the limits, not just notes.
All four risk controls live in the program's own loop, sitting between “evaluate the rule” and “send the order”, so nobody needs to watch the screen.

Hypothetical example

An account of NT$500,000, a daily maximum loss shutdown set at NT$10,000 and a cap of 2 contracts. In the morning the rule enters long 1 contract; at noon another signal adds 1 contract; when the third signal appears, the program checks that it is already at 2 contracts and sends no order. In the afternoon the loss builds to NT$12,000, past the NT$10,000 shutdown line, so the program closes both contracts at market and stops sending orders until it restarts the next day. Nobody watched the market during the whole process, and each of the four rules blocked something once.

How do you backtest a rule before placing a program order?

Before any rule sends its first program order, run it through a backtest that includes commission and slippage and fills at the next bar, then check it with out-of-sample data and walk-forward analysis. A backtest replays the rule over historical prices to see which orders it would place and how they turn out. Costs are included because every program order really does pay them; next-bar fills are used because the program decides at the bar's close and cannot fill at that bar's closing price; out-of-sample means the stretch of history that took no part in choosing the rule, and only it can score the rule fairly.

Below is a real backtest report, used to show how to read one. It tests NQ (Nasdaq-100 futures) daily bars, from 2019-01-02 to 2025-06-30, long and short with 1 contract each, with $20 commission and $10 slippage deducted per trade. Entries and exits use a single ADX indicator rule, with no stop loss, no profit target and no filters. It is a stand-in rule built from a standard indicator, not the subject of program orders itself; it is used only because its structure is simple and easy to read.

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

NumberResult
Net profit (closed trades)$102,875
Max drawdown$80,685
Trades43
Win rate58.14%
Profit factor1.436
Average trade$2,392.44
Time in market41.52%

How do you read these numbers? They are the one candidate the search kept, ranked by return to drawdown, after it tried 1,024 candidates. Picking the best of more than a thousand after the fact inflates the result by itself, and Bailey et al. (2014) work out clearly how much this kind of selection inflates it. So the net profit of $102,875 does not mean the ADX rule earned that money, and it is certainly not a number anyone can expect. What to look at is the proportions and the sample: the maximum drawdown of $80,685 is close to eighty percent of net profit, which means the rule has to absorb very deep pullbacks; 43 trades is few over six and a half years, and an average trade of $2,392.44 is easily swung by two or three big trades; time in market of 41.52% means it sat in cash for more than half of the days. These are the questions you have to answer for yourself before sending the first program order, and the report's job is to lay them out.

Look at how deep and how long the drawdown band under the equity curve runs, and whether the marked out-of-sample section keeps a slope close to the earlier section.
Look at how deep and how long the drawdown band under the equity curve runs, and whether the marked out-of-sample section keeps a slope close to the earlier section. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

One full-period backtest is only the first gate. Two things come next. Hold back a stretch of history that took no part in selection as out-of-sample, run it with the same cost settings, and see how much of the average trade survives. Then use walk-forward analysis (choose parameters on one stretch of data, run them unchanged on the next, and roll forward and repeat) to confirm the result does not rest on one market phase; Pardo (2008) gives a full account of the method. In AlphaPrime, strategy validation makes walk-forward analysis a fixed step, and a strategy that fails an earlier check stops there, which keeps the number of candidates that reach the end small.

Your next step is concrete: take the rule you plan to run as a program order and run an out-of-sample backtest with the same settings as above ($20 commission and $10 slippage per trade, or your futures broker's actual fees, with next-bar execution). Write down three numbers: average trade, maximum drawdown and number of trades. Then decide whether to send the first program order.

Frequently asked questions

Are a program order and program trading the same thing?

No. Program trading is the whole process: writing the rules, writing or obtaining the program, connecting to the futures broker's order channel, and monitoring and reconciling. A program order is only the last order that process sends. In everyday speech the two get mixed up, but when something goes wrong you need to separate them, because a wrong rule, a wrong program and a wrong connection are fixed in completely different ways.

Does the computer have to stay on to run program orders?

Yes. A program order is decided and sent by your own program, so if the computer shuts down or disconnects, the program stops and no new entry or exit signals are sent. That is why the program needs reconnection after a disconnect and reconciliation after reconnecting, and why you can also place a conditional order on the futures broker's server as a protective stop loss, which still triggers when the computer is off.

Can you use program orders and conditional orders together?

Yes, and it is a common practice. The program order handles entry, adding and exit for the whole strategy; the conditional order sits on the futures broker's server as a protective stop loss for when the computer disconnects. Watch the sync between the two: cancel the conditional order as soon as the program closes the position, or the conditional order will open an opposite position when it triggers.

How long should a paper account run before switching to live?

Decide by reconciliation results, not by number of days. Run at least until the program has been through an open, a close, a contract month change and one disconnect-and-reconnect, and every fill the program recorded matches the futures broker's report. Switch to live only after several consecutive weeks of reconciliation with no differences. On the first day after switching, use the smallest size and repeat the same reconciliation.

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.
  • U.S. Securities and Exchange Commission. Stop, Stop-Limit, and Trailing Stop Orders (Investor Bulletin). https://www.investor.gov/introduction-investing/general-resources/news-alerts/alerts-bulletins/investor-bulletins-15
  • U.S. Securities and Exchange Commission. Understanding Order Types (Investor Bulletin). https://www.investor.gov/introduction-investing/general-resources/news-alerts/alerts-bulletins/investor-bulletins-14