eTrader Help Center

The strategy tester and optimising inputs

Replay your Broker's price history through a bot, read the figures and the trades, and compare settings without fitting the past.

In short

  • Connect a trading account to test on your Broker's own price history.
  • Without one, the tester uses generated sample prices, good only for checking the code.
  • Results show net profit, trades, profit factor, max drawdown, the curve and every trade.
  • The tester uses each input's default. Change one value at a time and run again.
  • Settings that only work on one stretch of history are fitted to the past.

Robots and AI

Updated 7 October 2026, 4 min read

Before 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

  1. Make sure the Problems tab is clean. The tester needs a program that compiles, and the button stays off until it does.
  2. Pick the symbol and timeframe the bot is meant for.
  3. Set the starting balance and how many bars of history to replay.
  4. Press Run Test.

The Tester tab opens on the results when the replay finishes.

Read the results

FigureWhat it tells you
Net profitThe result over the whole test, in the account currency.
TradesHow many positions the bot opened and closed.
Profit factorGross profit divided by gross loss. Above 1 means the winners outweighed the losers over this stretch of history.
Max drawdownThe 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.

Test results come from recorded prices, not a forecast. Leveraged trading carries a high risk of loss.

Questions

Is my trading password saved when I connect an account to the tester?

No. The Login and password are checked once and never stored. eTrader Code only reads the account's price history for the tester.

Why does Run Test not respond?

The tester needs a program that compiles. Open the Problems tab, fix what it lists, and Run Test becomes available.

Why do I get the same result every time?

Tests are deterministic. The same code, inputs and candles give the same trades, so a result only changes when you change something.

Does a good backtest mean the bot will make money?

No. A backtest shows what the code would have done on past prices. Run the bot on a demo account or in Signals only mode before it trades money.

Related articles