Skip to content

Build

Build

Write the rules, test them on real prices, then decide.

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.

Cloud9Trader runs the whole loop of building a trading strategy in the browser: you write an algorithm, test it against past prices, tune its settings, and run it in a trading session. Everything runs on Cloud9Trader’s servers, so nothing depends on your computer staying on. New to the idea? Start with What algorithmic trading is.

An algorithm is your trading rules written as code. You write it in JavaScript in the Algorithms editor, and it runs on every price update or once per bar. Every save is kept as a version, and settings you want to change between runs are declared as externals.

It does not need to be much JavaScript: a few lines can read an indicator and open a position. It cannot reach the internet, read files or use outside libraries. Algorithms has the details, and Algorithm concepts explains how your code runs.

An indicator turns prices into a value, such as a moving average or the RSI. Sixty-seven are built in. You can call one in a line of an algorithm, draw it on a chart as an overlay or a study, read its source, or write your own in the same editor. Technical indicators has the list.

A backtest runs your algorithm against past prices to show what it would have done. Cloud9Trader stores the prices its brokers sent, tick by tick, and a backtest can replay either:

  • Every tick: each recorded price change, with its bid and ask, in order. This is the closest replay of what a live session would have seen, and it matters most when your stops and targets are close to the price.
  • Minute data: each minute as four prices. Much quicker, but it cannot tell whether the high or the low came first within a minute. Use it while you develop, and check the result on every tick.

What a backtest does not do: orders fill instantly at the recorded price, with no slippage, commission or financing, and no delay between deciding and filling. Live results will be somewhat worse, and past results do not predict future ones. Backtesting honestly explains what to allow for.

Backtests run on Cloud9Trader’s servers while you carry on working. Three run at once, and each member can have two running at a time, so one member’s batch cannot hold up everyone else. A further backtest waits in a queue until a place is free. Backtesting covers running one and reading its results.

An optimization runs many backtests over ranges of an algorithm’s externals and shows every result on one chart. It can try every combination, or use a genetic search, which breeds the best settings found so far into new ones and can search ranges too large to try in full. Its backtests run side by side.

What it does not do: optimizations run on minute data only, and a genetic search stops after at most 10,000 backtests. The best result is the setting that fitted the past most closely, which is not the same as the one that will work next. Re-run your choice on every tick and on a period it was not tuned on. Optimization and Overfitting and optimization explain how.

When a strategy holds up, a trading session runs it on the demo account or on your broker account, on the server. A session is not guaranteed to see every price: it sleeps at weekends, restarts if prices stop for an hour, and ends after repeated errors. Trading sessions are in beta. Practise on the demo account or a broker’s practice account first.

You can share an algorithm with the community. Members can then read its code, backtest it and clone it, but not change it. Algorithms you do not share stay private. Shared code is a starting point to read and test, not a recommendation. Sharing algorithms says what sharing makes visible.