Robots and AI
Updated 7 October 2026, 4 min readBefore a bot trades an account, run it through history. The tester in eTrader Code replays past candles through your program, candle by candle, with the same engine that runs bots in the cloud, and shows you every trade it would have taken. It tells you what the code does. It does not tell you what the market will do next.
Real prices or sample prices
The bar above the tester holds its settings: Account, Symbol, Timeframe, Balance and Bars.
Without an account, the tester runs on sample prices. They are generated, not taken from a Broker, and the results are marked Sample prices. They are fine for checking that the code does what you meant. They say nothing about how it would have traded.
For real history, connect a trading account from the Account field: choose your Broker, then the Server, and enter the Login and password. The Login and password are checked once and never stored, and eTrader Code only reads the account's price history. The results are then marked Broker prices, with the symbol, the timeframe, the number of bars and the dates they cover.
A demo account works for this. Testing on the Broker you will trade with matters, because each Broker has its own prices, spreads and trading hours.
Run a test
- Make sure the Problems tab is clean. The tester needs a program that compiles, and the button stays off until it does.
- Pick the symbol and timeframe the bot is meant for.
- Set the starting balance and how many bars of history to replay.
- Press Run Test.
The Tester tab opens on the results when the replay finishes.
Read the results
| Figure | What it tells you |
|---|---|
| Net profit | The result over the whole test, in the account currency. |
| Trades | How many positions the bot opened and closed. |
| Profit factor | Gross profit divided by gross loss. Above 1 means the winners outweighed the losers over this stretch of history. |
| Max drawdown | The deepest fall from a peak in the balance during the test. This is the number to size your account and your nerves against. |
Under the figures are the equity curve and the list of trades. Each trade shows its side, the price in, the price out, how long it was open, its profit and what closed it. Read a handful of those rows against the chart. If a trade closed for a reason you did not expect, that is where the code and your idea of it part ways.
If the bot hit errors, a box above the curve lists them as The bot stopped with errors. If it never traded, the tester says how many bars it replayed without opening a position.
The Journal tab holds everything the bot wrote with log.info during the test. A good journal line says what the bot saw and why it acted, which makes a surprising result quick to explain.
The same run repeats
A test is deterministic. The same code, the same inputs and the same candles give the same trades every time. Even a strategy that uses random numbers replays exactly, because the random sequence is seeded and recorded. When a result changes, something you changed caused it.
Inside the code, bot.isTesting is true during a test. Use it to skip anything that should only happen live, such as a push notification.
Optimising the inputs
Optimising means looking for the input values that suit a strategy best, such as the length of a moving average or the distance of a stop. The tester runs the program with the default value of each input, the number after = on each input line. To compare settings, change a default, run the test again and note the figures. The Inputs tab lists every input the program has, so you can see what there is to change. There is no automatic optimiser that tries many values for you: you compare settings by hand, one run at a time.
Change one input at a time. Two changes at once leave you unable to say which one moved the result.
Do not fit the past too closely
Given enough tries, some set of values will look excellent on any stretch of history. That is the risk of optimising: the settings end up describing the past, not a pattern that repeats. A few habits keep the test honest:
- Prefer settings where nearby values give similar results. A lone good number surrounded by poor ones is usually luck.
- Once you have settings you like, test them on a different stretch of history and on another instrument without changing anything.
- Watch the drawdown as closely as the profit. A higher profit bought with a much deeper drawdown is rarely a better bot.
- Keep the number of inputs small. Every extra input is another way to fit noise.
When the bot holds up, the next step is a demo account, or Signals only mode, in the cloud. See running bots in the cloud.