First algo trading strategy: a 30-day route for beginners
A 30-day route to a first algo trading strategy: spend week one writing one clear rule, for example "buy when the price breaks the high of the first 30 minutes", week two on software, clean data and costs, week three on the backtest, and week four on out-of-sample and walk-forward tests. Choose software by how you want to build rules: writing code yourself, or letting a generator search for them.
By Soren Huang · Published · updated · Editorial policy
Contents
- What is 程式交易 (algorithmic trading), and how does the workflow run?
- How do you turn a trading idea into exact rules?
- Which software do you need: a coding platform or a strategy generator?
- What data and costs do you need for TAIEX futures?
- Data: match the session and check the rolls
- Costs: three items on every trade
- How do you know a backtest is not just luck?
- Write your pass rules before the first test
- What mistake do beginners make most often?
- How do you move a tested strategy to live trading?
- Frequently asked questions
- References
Thirty days is enough to take a first algo trading strategy from idea to a verdict. Week one: write one idea as exact rules. Week two: choose software, then get clean historical data with commission, tax and slippage included. Week three: run the test. Week four: check it on data the rules never saw, using out-of-sample and walk-forward tests.
What is 程式交易 (algorithmic trading), and how does the workflow run?
Algorithmic trading (程式交易) is trading where a computer follows a fixed set of written rules to decide when to enter and exit, and it runs from a written rule to a tested strategy to live orders. Quantitative trading (量化交易) means using data and statistics to make those rules. In retail futures trading, the two words describe almost the same work.
The workflow below is the same whether you trade TAIEX futures, Mini-TAIEX or US index futures:
- Idea. Write the idea in one sentence, for example "buy when the price breaks the high of the first 30 minutes".
- Rules. Turn the sentence into exact conditions: entry, exit, stop, position size and the session it trades.
- Data. Prepare clean bar data with the right session and contract rolls.
- Backtest. A backtest is a simulation that runs your rules over historical data and records every trade they would have taken. Include all costs and fill orders on the next bar.
- Validate. Test the rules on data they were not built on.
- Review. Read the equity curve, the drawdown and the list of trades, not only the final profit.
- Export and simulate. Move the strategy to your trading platform and run it in simulation.
- Go live small. Trade one contract and compare live fills with the backtest.
How do you turn a trading idea into exact rules?
An idea becomes a testable rule when every word that could be read two ways has one fixed meaning, written down before the first test. Most beginner coding errors come from vague rules, not from the programming language. The table takes the idea from step 1 and fixes each vague word. The exact versions are example choices, not recommendations.
| Vague word | Question to answer | One exact version |
|---|---|---|
| "First 30 minutes" | Which session, which bars? | TAIEX futures regular session, the bars from 08:45 to 09:15 Taiwan time |
| "Breaks the high" | A touch, a trade above, or a close above? | A bar closes above the highest high of those bars |
| "Buy" | Which order, on which bar? | Market order at the open of the next bar |
| "Stop" | Where, and does it move? | Fixed stop at the lowest low of the first 30 minutes |
| "Exit" | What ends a trade that is not stopped out? | Exit at the open of the 13:30 bar |
| "Trade" | How often, which direction, what size? | At most one long trade per day, one contract |
Use a simple test: give the rules to a friend with a chart. If they mark the same trades as you without asking a question, the rules are exact. Each row then becomes one line of code on a coding platform or one setting in a strategy generator.
Which software do you need: a coding platform or a strategy generator?
Pick a coding platform if you already have a specific idea to test, and a strategy generator if you want to search many rule combinations. A coding platform is charting and trading software with its own scripting language, in which you write each strategy by hand. A strategy generator is software that builds and tests many rule combinations from building blocks you choose, such as indicators, parameter ranges and exit types.
| Coding platform | Strategy generator | |
|---|---|---|
| What you do | Write every rule in code | Set building blocks, ranges and limits |
| Skill needed | The platform's scripting language | Clear research settings; no coding to search |
| Strategies tested | The ones you write | Many variants from one setup |
| Main risk | Coding errors, slow testing of ideas | Picking the variant that fit the past by luck |
| Suits | Testing one known idea precisely | Exploring which rules hold up on a market |
Many traders use both. Writing each variant by hand limits you to the few ideas you can code; a generator tests many variants from one setup. A coding platform is still where the order reaches the market. Common platforms each have their own language: MultiCharts uses PowerLanguage, TradingView uses Pine Script, TradeStation uses EasyLanguage and NinjaTrader uses NinjaScript.
In AlphaPrime (Valynox), strategy generation turns your research settings into testable entry and exit rules, so you set the rules, parameter ranges and search limits instead of typing each strategy.
What data and costs do you need for TAIEX futures?
You need bar data that matches the session you will trade and a cost model with commission, futures transaction tax and slippage. Without both, the backtest describes a market you cannot actually trade.
Data: match the session and check the rolls
Test with the same session choice (day-only or full-session) you will trade, and check where your continuous contract rolls. A continuous contract is a price series that joins the monthly contracts into one long history. Our guide to day-only vs full-session bars in futures backtests shows why the session choice changes the signals. In AlphaPrime, the backtesting settings for trading sessions let you run one TAIEX futures rule on day-only bars and again on full-session bars, then compare the two.
Costs: three items on every trade
Each contract has a fixed value per index point: NT$200 for TAIEX futures (TX), NT$50 for Mini-TAIEX (MTX) and NT$10 for Micro-TAIEX (TMF). The futures transaction tax on stock index futures is charged on each side of the trade:
Tax per side = index level × point value × 0.00002
Here "index level" is the futures price in points, "point value" is the money value of one point for your contract, and 0.00002 is the tax rate (two in one hundred thousand). Add your broker's commission for each side and at least one point of slippage per side. Slippage is the difference between the price your backtest assumed and the price you actually get. Exchanges and regulators can change these values, so check the TAIFEX contract page before you set up a test. The futures contract calculator shows tick value, point value and the profit or loss of a trade.
Hypothetical example
One Mini-TAIEX contract at an index level of 20,000 is worth 20,000 × NT$50 = NT$1,000,000. Tax is NT$20 per side, NT$40 for the round trip. Assume commission of NT$50 per side (NT$100 round trip) and slippage of one point per side (NT$100 round trip). The total round-trip cost is NT$240, which is 4.8 points. The strategy's average trade must be well above 4.8 points before costs, or it loses money after them.
How do you know a backtest is not just luck?
You test the strategy on data it was not built on, first with an out-of-sample period and then with walk-forward analysis. Think of a practice exam: if you studied with the answer key, a perfect score says nothing. Only a new exam shows what you learned.
In-sample data is the part of history you use to build and tune the strategy. Out-of-sample data is a later part of history you keep aside and use only once, after the rules are fixed. If a strategy earns well in-sample but loses or falls flat out-of-sample, it learned noise.
Walk-forward analysis is a repeated out-of-sample test that moves forward through history window by window. Our guide to walk-forward analysis explains how to choose window lengths and read the results.
Write your pass rules before the first test
Decide what counts as a pass before you see any result, because rules chosen after the result tend to fit that result.
| Decide in advance | Why it matters |
|---|---|
| The out-of-sample period | Fixing it first means you can never tune on it by accident |
| The minimum number of trades | With few trades, the result is mostly chance |
| The average trade compared with the round-trip cost | The cost in points from the example above sets the floor |
| The largest drawdown you accept | It must be a loss you could sit through on your own account |
| How many variants you will test | The more you test, the more luck is in the best one |
Hypothetical example
Before the first test you write: the most recent two years stay closed as out-of-sample data; at least 100 out-of-sample trades; an average trade of at least 15 points before costs, about three times the 4.8-point Mini-TAIEX cost; a largest drawdown of no more than NT$100,000 on one contract; at most 200 variants. A strategy with a strong in-sample result but only 60 out-of-sample trades fails the second rule. You do not lower the rule to let it pass.
AlphaPrime's strategy validation offers Basic, Standard and Extensive validation with walk-forward analysis and custom thresholds, and stops the later checks when a strategy fails one. Your written pass rules are the numbers you enter as those thresholds.
What mistake do beginners make most often?
The most common mistake is overfitting, and the simplest defence is a written log of everything you tested. Overfitting is when a strategy's rules match the random details of past prices instead of a pattern that repeats. It is like tailoring a suit to one photo of a person: it fits the photo perfectly and the person badly.
The more variants you test, the more likely the best one is good by chance. Research on backtest overfitting shows that testing many variants can produce an impressive backtest with no real edge behind it (Bailey et al., 2014), and that reported backtest results should be discounted for the number of tests run (Harvey & Liu, 2015).
Hypothetical example
You test 500 moving-average settings on Mini-TAIEX. None has a real edge, but by chance a few look strong. You pick the best one, with a smooth equity curve. Out-of-sample it loses money, because it was selected for luck, not skill.
A research log makes the number of tests visible. For each idea, record:
- The date and the idea in one sentence.
- The number of variants tested, including the ones you threw away.
- Every rule change and the reason for it.
- The cost settings, in index points.
- The day you opened the out-of-sample data, and what it showed.
When the log shows 300 variants behind one idea, treat the best result with far more doubt than a result that came from three variants. The log also shows at once if you are about to reuse out-of-sample data.
How do you move a tested strategy to live trading?
Export the strategy to your platform, check that it trades the same way on a sample period, run it in simulation, then trade one contract. AlphaPrime's platform export writes the strategy as source code for MultiCharts (PowerLanguage), TradingView (Pine Script v6), TradeStation (EasyLanguage), NinjaTrader (NinjaScript), MetaTrader 4 (MQL4) and MetaTrader 5 (MQL5).
- Load the same symbol, bar size and session on the platform as in the backtest.
- Compare entries and exits on a few weeks of data. Small differences usually come from the data feed or session settings, so fix those first.
- Run the strategy in simulation for several weeks and compare fills with the backtest's assumed prices.
- Go live with one contract and measure your real slippage. Feed that number back into your next backtests.
What this means if you use AlphaPrime: you set the research building blocks and costs once, AlphaPrime searches and tests rules with fees, slippage and next-bar execution, and validation filters out the variants that fail your own thresholds before you export anything.
Frequently asked questions
Do I need to know programming to start 程式交易?
No. You need to write rules precisely, which is a different skill from writing code. A strategy generator lets you search rules without coding, and you can export finished strategies as source code. Learning to read your platform's language still helps when you check the exported strategy.
Which 程式交易軟體 should a beginner choose?
Choose by how you want to work. If you have one idea to test, a coding platform lets you write it exactly. If you want to explore many rule combinations, a strategy generator does the search, and the strategy then runs on your trading platform.
How much historical data do I need for a TAIEX futures backtest?
Enough to include rising, falling and sideways markets and enough trades to judge the result. Many traders use several years of bars. Keep the most recent part aside as out-of-sample data, and use the same session (day-only or full) that you plan to trade.
Does a good backtest mean the strategy will make money?
No. A backtest describes how rules behaved on past data; it is not a forecast. Out-of-sample and walk-forward results show whether the way you built the strategy held up on unseen data, which is a stronger test than one backtest.
What is the difference between 程式交易 and 量化交易?
量化交易 (quantitative trading) uses data and statistics to design trading decisions. 程式交易 (algorithmic trading) means a computer executes fixed rules. For a retail futures trader, the work is mostly the same: build rules from data, test them and let software execute them.
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.
- Harvey, C. R., & Liu, Y. (2015). Backtesting. The Journal of Portfolio Management, 42(1), 13–28.

