Algorithm comparison
A comparison simulation of SMA Crossover, RSI Threshold and Buy and Hold on BTCUSDT, how to read the comparison card, and the same strategy as an instrument sweep.
A return on its own says little. A strategy that made 20% sounds good until you learn that simply holding the asset made 35% over the same year. In this tutorial you put two strategies and a yardstick side by side in one simulation, read which did best, and then ask a second question: does the better strategy work on other instruments too?
It builds on First backtest. Do that one first if you have not created a simulation before.
Comparisons and instrument sweeps depend on your plan. See Plans and quotas.
The example
| Part | Choice |
|---|---|
| Algorithms | SMA Crossover, RSI Threshold and Buy and Hold |
| Instrument | BTCUSDT |
| Candles | Hourly (1h), over the latest twelve complete months |
| Starting balance | 10,000 USDT for each algorithm |
- SMA Crossover follows trends: it buys when a fast moving average crosses above a slow one and sells when it crosses back.
- RSI Threshold does the opposite kind of thing: it buys when the RSI indicator rises back through an oversold level and sells when it falls back through an overbought one.
- Buy and Hold is the yardstick. It buys once with the whole balance and holds to the end. A strategy that cannot beat it has only added effort and fees.
In a comparison each algorithm gets its own account, and every account starts with the same balance. No algorithm can spend another's money, so the results compare fairly. See Comparison.
Part 1: comparison simulation
Details, balance and data
- On the Simulations page, select New Simulation.
- On Details: enter the name
BTC strategy comparison, choose Comparison under Type, pickUSDTas the Quote asset, and leave the fees at 0.1 and Margin off. Select Next. - On Balances: add
10000USDT. Each algorithm's account starts with a copy of this balance. Select Next. - On Data: select the add button, select the Last year preset, set the
interval to
1h, search forBTCUSDT, select it and select Add. Select Next.
Three algorithms
On the Algorithms step you add each algorithm and tell it which data to read. In a comparison this link is yours to make, because different algorithms may read different data.
- Select the add button (the plus icon). The Add algorithm dialog opens.
- Select SMA Crossover, leave its label and parameters as they are, and select Add.
- On the new row, select the sources button, which reads 0 sources, and
tick
BTCUSDT. The row now says "Reads BTCUSDT". - Select the add button again, select RSI Threshold, and select Add.
Its defaults are a Period of 14, an Oversold Threshold of 30 and an
Overbought Threshold of 70. Link it to
BTCUSDTin the same way. - Add Buy and Hold a third time round. It has no parameters. Link it to
BTCUSDT. - Check that all three rows say "Reads BTCUSDT". An algorithm that reads nothing has nothing to trade.
- Select Next.
Creation and run
- On Review, check that the type is Comparison and that there are 3 algorithms. Tick Open it and select Create simulation.
- On the simulation's page, select Run.
- Wait for the run to complete. All three algorithms run in the one run, over the same candles.
Part 2: comparison results
Summary
The run's summary card reads differently from a single-account run. Three separate accounts have no meaningful total, so instead of one return it shows the edges:
- Best return, with the name of the algorithm that made it.
- Worst return, with its algorithm.
- Worst drawdown, the deepest fall any of the three took, with its algorithm.
The chart under the figures draws all three accounts on one axis.
In the Runs table, select the chevron at the start of the run's row to unfold one line per algorithm.
Comparison card
- Select Open full results.
- Find the Every algorithm card. It has a ranked table on one side and a chart of the three net worth lines on the other.
Read the table column by column:
- # ranks the algorithms by Return, best first. Look at where Buy and Hold stands. Any algorithm ranked below it lost to doing nothing clever.
- End is each account's final value in USDT. Every account started at 10,000, so the differences are directly comparable.
- Max drawdown often tells a different story from the return. Buy and Hold takes every fall of the market in full. A strategy that steps aside during falls can end lower and still have been far easier to hold. Decide which matters more to you before you look at the ranking.
- Win rate is the share of closed trades that made money. Buy and Hold shows a dash: it never sold, so it closed no trade and has no win rate. A dash is never a zero.
- Orders filled shows how busy each algorithm was. Every fill paid a fee, so a busy algorithm starts each trade a little behind.
Then read the chart:
- Follow the three lines through the year. Notice where they part: a trend-following strategy tends to lag in a choppy stretch and keep up in a long move, and a mean-reversion strategy tends to do the reverse.
- Untick a row to hide its line and see the other two more clearly. Tick it to bring it back.
- Select the quote-asset button above the chart to see the lines in USDT instead of percent.
One algorithm in detail
- Select the SMA Crossover row in the table. The page scrolls to One algorithm in detail, which now shows that algorithm: its net worth, the candles with its orders marked, and its journal.
- Select the RSI Threshold row. The same section now shows the other strategy's orders on the same candles. Compare where each one bought and sold.
See Run results for everything on this page.
Parameter comparison
The same simulation can compare settings of one strategy.
- Return to the simulation's page.
- On the Algorithms card, select the add button and select SMA Crossover again.
- Set Label to
SMA 20/50, Fast Period to 20 and Slow Period to 50, and select Add. - Link the new row to
BTCUSDTwith its sources button. - Select Run.
The new run ranks four accounts, with both versions of the crossover among them. The first copy still carries the label "SMA Crossover", so the two are easy to tell apart.
Part 3: instrument sweep
Suppose SMA Crossover came out ahead on Bitcoin. That may be skill or luck. An instrument sweep runs one setup on several instruments, each on its own account, so you can see where the strategy works. See Instrument sweep.
Sweep creation
- On the Simulations page, select New Simulation.
- On Details: enter the name
SMA crossover sweep, choose Instrument sweep, pickUSDTas the Quote asset. Select Next. - On Balances: add
10000USDT. Each instrument's account starts with it. Select Next. - On Data: select the add button, select Last year, set the interval
to
1h, then search for and selectBTCUSDT,ETHUSDTandSOLUSDT, one after another. The button now reads Add 3 sources. Select it, then Next. - On Algorithms: select the add button, select SMA Crossover, keep the default parameters and select Select. Select Next.
- On Review, the Algorithms line reads "1 algorithm, run once on each of 3 instruments". Tick Open it and select Create simulation.
- Select Run.
Two rules keep a sweep fair, and the app holds you to both: every instrument uses the same interval, and every instrument runs the same algorithm with the same parameters. The only thing that differs between the accounts is the market. All three instruments here are priced in USDT, the quote asset, so every result is in the same money.
On the simulation's page, the Algorithms card shows the setup once, not three copies. Change a parameter there and it changes on every instrument.
Sweep results
Open the run with Open full results. The page is the comparison page you have just read, with one word changed: the card is titled Every instrument, and each row is named after the instrument it traded.
- Read the ranking. It now orders instruments, not strategies: where did this strategy do best?
- Compare the spread. Similar results across the three suggest the rules capture something general. One strong result and two weak ones suggest the strong one was a matter of that market, or of luck.
- Select a row to inspect the strategy on that instrument: its orders on that instrument's candles, and its journal.
A sweep compares the strategy with itself across markets. It does not tell you whether the strategy beat holding each instrument. For that, make a comparison on that instrument, as in Part 1.
Past results
These rankings describe one year that has already happened. A strategy that led on every instrument can still lose next year. Use comparisons to rule ideas out and to understand how a strategy behaves, then watch what survives in a live simulation, where no money is at risk, before you consider trading it.
Summary
- Created a comparison, gave three algorithms an account each, and linked each to its data.
- Read the comparison card: rank, ending value, drawdown, win rate and activity, then one algorithm in detail.
- Added a second copy of an algorithm with different parameters.
- Ran one setup across three instruments as a sweep and read where it worked.
Related
- Simulations: the three kinds and when to use each
- Algorithm setup: labels, parameters, groups
- Run results
- Results
- Built-in algorithms
- First plugin: write an algorithm of your own to compare
First backtest
A complete first backtest in the app: SMA Crossover on BTCUSDT with hourly candles and 10,000 USDT, from creating the simulation to reading the results and trying a second set of parameters.
First plugin
A walkthrough from the plugin skeleton to an algorithm of your own, built, added to Neurotrader and running in a simulation.