Test your robot in the Strategy Tester

MetaTrader 5 has a built-in Strategy Tester. It replays past prices, so you can see how your rules would have traded. How to run it, read the result and save it. Past results do not tell you what will happen next.

Which file to test

When your robot passes the check, you will be able to download a free test copy. It runs only in the Strategy Tester, so you can test your rules on past prices before you get the robot for your accounts.

The robot you get for your accounts runs in the Strategy Tester too, whatever account MetaTrader is logged in to. Test either one the same way.

Your robot's numbers are built into the file, so there is nothing to load before a test. Put the file in the Experts folder first: how to copy it there.

Good to know

What a test can and cannot tell you

  • How your rules would have traded on past prices
  • How often it trades, and how large its losses were
  • Whether a safety limit would have stopped it, and when

It cannot tell you

  • What will happen next
  • The spreads, slippage and delays of live trading
  • Whether your rules suit you

Run a test

Choose the symbol and the bars your robot was built for. Each example robot's page names them. If your broker adds letters to its symbol names (EURUSD.m, for example), choose that symbol and type the extra letters into the robot's symbol suffix input on the Inputs tab.

Start the dates early enough: a robot whose rules use a 200-bar average needs 200 bars before its first trade. A longer test, over different kinds of market, says more than a short one.

In MetaTrader 5

Test it in the Strategy Tester

  1. Open View then Strategy Tester, or press Ctrl+R.

  2. On the Settings tab, choose your robot under Expert, then the symbol it trades, the timeframe (its bars) and the dates.

  3. For Modelling, "Every tick based on real ticks" is the most detailed choice when your broker provides it. Set the deposit and the leverage like your own account.

  4. Press Start. The Graph tab draws the balance as the test runs, and the Journal tab shows what the robot wrote.

  5. To keep the result, right-click in the Backtest tab when the test finishes, choose Report, then HTML. Save the file.

Email and push messages are not sent from the tester, and the robot's Stop button does not show there.

Reading the result

The Backtest tab lists every trade. The report shows how many trades there were, how many won and lost, the largest loss, and the drawdown: the deepest fall from a high point to the next low.

Look at the losses before the gains. A robot that trades rarely and loses little in a bad month is easier to live with than one that looks good on paper and lost a quarter of the account in a week. Check that the safety limits stopped it where you expected.

Then change one thing at a time in the builder and test again. A robot that only looks good with one exact set of numbers, over one short period, is unlikely to look the same on new prices.

Watch it trade

Visual mode

On the Settings tab, tick Visual mode before you press Start. The tester opens a chart and plays the test on it, trade by trade, with a slider to slow it down or speed it up. It is the best way to see whether a rule fires when you meant it to.

The news file, for robots that pause around news

A robot with a pause around news reads MetaTrader's own economic calendar on a live chart. The calendar does not work inside the Strategy Tester, so there the robot reads a file of news times instead. Without that file it stays out of the market and opens no trades in a test.

Our free news helper writes that file. It is a small MetaTrader script: you run it once on any live chart, choose the dates, and it writes the calendar to a file in MetaTrader's common files folder, where your robot looks for it. It trades nothing and contacts no website.

Download the news helper

In MetaTrader 5

Make the news file

  1. Download the helper. Its name is TTR_NewsExport.ex5.

  2. Choose File then Open Data Folder. Open MQL5, then Scripts, and copy the helper there. In the Navigator, right-click Scripts and choose Refresh.

  3. Drag the helper from the Navigator onto any chart that is connected to your broker (not the tester's chart). In the window that opens, choose the first and the last date your test covers, and press OK.

  4. The helper writes the file and says so in the Experts tab. It is in the common files folder, under TTR, as news.csv. Run your test again.

Run the helper again when you test later dates: the file holds only the dates you chose.

Join the waitlist

We will email you once, when TheTradingRobot opens.