What algorithmic trading is
Trading on margin can lose you more than you put in. Past results, including backtests, do not predict future results. Cloud9Trader provides tools and education, not financial advice. Read the full risk warning.
Algorithmic trading means writing your trading rules as a program and letting a computer follow them. The program watches prices and decides when to open and close positions, the same way every time, without getting tired or nervous.
What it does well:
- It follows the rules exactly, including the stop loss you might hesitate over.
- It can be backtested: run against past prices to see what the rules would have done.
- It can watch markets around the clock.
Where it goes wrong:
- A rule that worked in the past can stop working. Markets change.
- Overfitting: tune a rule until it fits the past perfectly and it usually fails on new data.
- Code has bugs, and an unattended program repeats a mistake quickly.
- Backtests leave out real-world costs and delays unless you account for them.
A worked example
Section titled “A worked example”A rule in words: “When the price closes above its 20-bar moving average, buy 10,000 units with a 15-pip stop loss and a 30-pip take profit. Hold one position at a time.”
That rule decides everything: when to enter, how much, and when to exit. Each winning trade gains 30 pips and each losing trade loses 15 (before the spread), so it breaks even if a little over one trade in three wins. A backtest tells you how often it won in the past, which is evidence, not a promise.
In Cloud9Trader
Section titled “In Cloud9Trader”You write an algorithm in JavaScript on the Algorithms screen. It runs each time the price updates, in onTick, or once per bar, in onIntervalClose, and opens positions with openPosition. Settings you want to vary are declared as externals. You then backtest it, optimize its externals, and run it in a trading session on a demo or broker account.
Read next
Section titled “Read next”- Build: what each part of Cloud9Trader does, and what it does not do.
- Get started: clone an algorithm, backtest it and run it on a demo account.