What Is Algorithmic Trading?
Algorithmic trading means writing a trading rule precisely enough that a computer can execute it. The difficulty is rarely the code — it is that most rules people describe are missing an exit, a size, a timeframe, or a definition of the terms they use.
The interesting part is not the automation. It is that writing a rule precisely enough to automate exposes how much of it you had not decided.
How it works
Here is a complete, unambiguous entry rule: buy when the close crosses above the 20-bar simple moving average.
A computer can execute that with no further instruction. It is about as simple as a rule can be and still be a rule.
It fired 14 times across this history.
What the rule does not say
When do you get out? The rule is silent. Invent one — exit when the close falls back below the average — and the holds run from 1 bar to 12, median 5.
Change the exit and every number about this strategy changes. The entry you specified is the part you thought about; the exit you did not specify is doing at least as much of the work.
How big is the position? Also silent, and that is the risk management page — the input that decides whether the whole thing is survivable.
Which chart does it run on? Silent again, and it matters enormously.
Every parameter is a decision
Lengths 5 through 60 produced between 8 and 18 signals on this same history.
There is no length in there that is correct. Each one is a different strategy wearing the same description, and “I use a moving average crossover” identifies a family rather than a method.
The temptation is obvious and it has a name. Try every length, keep the one that looks best on the history you tested, and you have measured which parameter fitted the past — not which one describes the market.
The value is the writing, not the running
Most people who go through this exercise never automate anything, and it is still worth doing.
Try to write your own approach as a rule. The sentence will stop somewhere — at “when the structure looks right”, or “when there’s enough confirmation”, or “when it’s a good setup”. Those are not vague because you are bad at writing; they are vague because the decision underneath them had not been made.
Every place the sentence stops is a decision you have been making differently each time, and you cannot review a decision you never wrote down. That is worth more than any bot.
Three things a backtest will not tell you
Once the rule is complete you can run it over history, and there are three standard ways that result comes out better than the real thing would have.
Look-ahead. Using information the moment it did not exist yet. The commonest version is acting on a bar’s close at that close — you only knew the close once the bar had ended, so the earliest price you could actually be filled at is the next bar.
Survivorship. Testing on the instruments that still exist. A rule run over today’s index members never traded the companies that were removed, which is exactly the set that did badly.
Costs. A backtest with no spread and no commission is measuring a market nobody trades in. The scalping page puts numbers on this: a fixed round trip is 4.1% of a typical bar on the fastest chart and 0.5% on the slowest, so a rule that trades often is far more sensitive to this omission than one that does not.
All three flatter fast strategies most, which is why the results that look most impressive are usually the ones with the most trades in them.
A worked example
Write the entry as a sentence a stranger could follow. No adjectives.
Then write the exit. Both exits — the one where you were right and the one where you were wrong.
Then the size, as a rule, from the distance to the invalidation.
Then the universe and the timeframe. Which instruments, which chart.
Now count what you have. If the answer is five specific sentences, you have a strategy. If it is one sentence and four “it depends”, you have a habit — and the habit may well be good, but it cannot be reviewed, tested, or taught, including to yourself next month.
The original data
Across our study of 24,971 trading videos, 496 cover algorithmic trading. The median one gets 6,804 views, 77% never pass 50,000, and the median length is 10.8 minutes.
The corpus carries description text for only 16 of those 496 — much the thinnest sample in this glossary relative to field size — so no claim is made here about how the topic is written.
One observation is safe: 496 videos on automating strategies, against risk management and entry and exit, which are the two things any of those strategies would actually need specified.
When it fails
Half the signals reverse immediately
7 of 14 within 3 bars. 9 of 14 within 5.
A rule that is precise is not a rule that is right. Automation removes hesitation and inconsistency; it does not supply an edge, and a bad rule executed perfectly is a bad rule executed more often.
The same rule on a different chart is a different rule
Nothing about the sentence changed and the behaviour did. A rule without a timeframe is not complete, however precisely the rest of it is worded.
You tested it on the history you tuned it on
Covered above. Choosing the parameter that performed best on a period, and then judging it on that same period, measures nothing — and it is the single most common error in this whole subject.
You judged the signal with the chart finished
On a completed chart the good crossovers are obvious. At the signal there are 14 of them and half are about to reverse, with nothing to separate the two — which is the same right-hand-edge problem as every other page here, and the reason automation is appealing in the first place.
Related
Entry and exit is the half of a rule most people leave unspecified.
Risk management is the sizing rule that turns a signal into a position.
And moving average is the tool the example rule is built on, including why its length is a choice rather than a setting.
I do not run bots and I still think everyone should try to write their strategy as a rule, because the exercise is brutal in a useful way. The first time I tried it I could not finish the sentence - I knew what I meant by a good setup and I could not say it in a way a computer would accept. That gap between what I thought I was doing and what I could actually specify was worth more to me than any indicator.
— Michael Whitman, from this video
This page is educational, not financial advice. Test every idea on your own charts before risking money.