If you’re testing a trading strategy for the first time, this guide shows you how to set up and read a MetaTrader 5 test and how to use TradingView’s Strategy Report. To test trading strategies on past prices, write down when to open and close a trade, how much to trade and which costs to include. Reserve some past dates before looking at results, then apply your fixed rules to historical prices without placing live trades and save the report and run log even if the test loses money. This is backtesting, and what it shows about losses, falls from a previous peak in account value (drawdowns) and other weaknesses depends on your rules, price data and assumptions about how orders are filled.
The MetaTrader 5 (MT5) example uses the euro against the US dollar (EURUSD) and groups prices into one-hour bars. If you are still designing your trading rules before running tests, start with the guide to developing a trading strategy, or see how Expert Advisors work in MetaTrader for automated trading programs.
What testing trading strategies on past prices can show
A historical test shows how fixed rules would have behaved on the selected prices under the chosen order settings. Past results cannot establish how the rules will perform in live trading. Keep the four common testing methods distinct because each answers a different question:
- Historical holdout: a past date window set aside before evaluating results so you can test fixed inputs on unseen past data without fitting them to that period.
- Rolling walk-forward: repeats parameter selection and testing on unseen past data across successive moving windows.
- Realtime forward observation: records what happens on new market data arriving after the rules are frozen.
- Discretionary replay: reveals past bars one by one while a person makes manual trading decisions.
In the worked example, the back window is the earlier test period. The historical forward window is the later period reserved to check the same automated rules.
Five things to record before you run a test
A result looks convincing until you try to reproduce it, so lock five items before opening a strategy tester:
- Write the rules first. Record entry, exit, position sizing, trading hours, indicator warmup (the initial bars an indicator needs before producing valid values) and how open positions are handled at the end of a window. Save the code and inputs before viewing outcomes.
- Identify the data. Record the data provider, exact ticker symbol, length of each price bar, how the source records dates and times, and the dates you ask the tester to cover. Check for missing bars, missing ticks (individual price updates), conversion history (exchange rates converting trade profits into your account currency) and the prior history needed before the first evaluated bar.
- Set the financial assumptions. Save starting capital, account currency, leverage (controlling a larger position than your deposit) and sizing rules, plus spreads (the gap between buy and sell prices), commission, financing and slippage (filling at a different price than expected) assumptions. A commission total of zero in a report is a result of that test, not a general claim that trading has no costs.
- Reserve the holdout. Declare its dates and evaluation criteria before examining results. If you change inputs after reading the holdout, that period has become part of development.
- Keep the complete record. Save unsuccessful runs as well as favourable ones. Record any data correction and its reason rather than silently replacing a poor result.
Running a fixed test in MetaTrader 5
The MT5 worked example below uses MetaQuotes’ installed Moving Average Expert Advisor sample (an automated trading program for MetaTrader). The saved configurations and tester reports establish the exact settings and historical outcomes, while the menu steps and alternative mode descriptions come from MetaQuotes’ MetaTrader 5 Help documentation.
- Open the Strategy Tester with Ctrl+R and choose the Moving Average expert under
Examples\Moving Average. Keep a copy of the installed source and executable because another installation may contain a different version. - Select
EURUSDon the hourly (H1) timeframe (bar length). Enter the date windows shown in the split table below; MT5 excludes the end date. Set account currency to EUR, starting deposit to 10,000.00 EUR and leverage to 1:30. Each segment starts with a fresh deposit. - Load the preset (the saved settings file) and check every value. Use the same program and settings for both ways of modelling prices and in both date windows. To repeat the separate runs, turn off Optimisation (searching for settings) and Forward (the tester’s automatic split).
- Choose the price-modelling mode, inspect the symbol specification (the platform’s settings for that instrument) and commission settings, and record the execution assumptions. Advanced tester settings allow predefined account commissions or a configured schedule; configuration files alone do not preserve the entire symbol specification or cost schedule.
- Start the test, then inspect the tester journal (the platform’s run log) for the actual interval, loaded inputs and data warnings. Save the report and its adjacent images under a distinct name for each run, and compare the report dates with the first and last deals (individual order executions). The dates you entered alone cannot establish what the report covers.
More info: test checklist and MetaTrader 5 downloads
Reproducibility checklist
- Save the exact strategy source, executable and input preset, and record the platform version.
- Record the feed, symbol specification, bar length (timeframe), time zone, history coverage and indicator warmup.
- Declare the back and holdout windows, including end-date handling, before looking at outcomes.
- Save capital, currency, leverage, sizing, commission, swap (charges or credits for holding trades across sessions) and execution settings.
- Check loaded inputs, actual pass dates and data warnings in the journal.
- Save complete reports, charts and deal records; reconcile costs, net result (profit or loss after recorded costs) and balance.
- Keep each capital reset visible, and label equity drawdown (a drop from a peak that also counts open trades) as a report value unless an equity series supports a reconstruction.
- Preserve losing runs, count discrepancies and any difference between requested and available history.
Configuration and preset downloads (tester settings only, not a strategy recommendation): Remove the trailing .txt suffix from each configuration file to leave .ini. Save the input preset specifically as p01a-moving-average.set inside MQL5\Profiles\Tester in the terminal’s data folder—every configuration references that exact filename under ExpertParameters, so merely removing .txt leaves a different filename. The .ini files are terminal startup configurations, while the .set file contains expert inputs; the installed expert must match the sample used here, and report paths are relative to the terminal environment. Each configuration replaces any existing report at its destination and closes the terminal when finished, so run in a dedicated tester session after saving other work. Close the dedicated terminal, open PowerShell in the folder holding its installed executable, and run .\terminal64.exe /config:"FULL_PATH_TO_INI" with the chosen configuration’s full path. Use the four separate segment configurations to reproduce the segment outcome table; if entering settings manually, leave both optimisation and Forward disabled.
- Minute OHLC (open, high, low and close) / original split configuration (.ini.txt)
- Recorded-tick mode / original split configuration (.ini.txt)
- Minute OHLC / back segment configuration (.ini.txt)
- Minute OHLC / forward segment configuration (.ini.txt)
- Recorded-tick mode / back segment configuration (.ini.txt)
- Recorded-tick mode / forward segment configuration (.ini.txt)
- Moving Average input preset (save as p01a-moving-average.set)
Choosing how the tester builds price data
The four MT5 options below show different ways the tester can build the prices it uses. Every tick generates ticks from minute history. Every tick based on real ticks, called recorded-tick mode below, uses saved price updates where available. The tester can generate replacements when suitable minute data exists, including for the gaps documented in this example. Minute OHLC uses each minute’s open, high, low and close prices. Open prices only evaluates the expert at bar openings. Order and stop handling also depends on the modelling mode; do not assume that this describes every execution check performed by the tester. No run in this guide used Open prices only.
Recorded ticks can carry spread changes within a minute, whereas generated ticks use the minute-bar spread. Model choice therefore changes more than speed, and a result from a coarser model does not establish how an intrabar rule (a rule that triggers inside a bar before it closes) would behave on more detailed prices.
More info: data source and gaps in recorded prices
The saved MT5 runs are dated 5 October 2026. They use EURUSD hourly history and recorded price updates from a Moneta Markets MT5 server on MetaTrader 5 build 6230. The server name identifies the data source alone. The times are the ones shown by the terminal, with no server time zone or daylight-saving rule assumed. Use the same convention when comparing runs.
The table below summarises the minutes in each recorded-tick segment where the MT5 journal reported absent or discarded ticks and fell back to generated ticks.
| Model / window | Tick status | Minutes | Minute bars | Share |
|---|---|---|---|---|
| Recorded-tick mode / back | Absent | 11 | 278,829 | 0.003945% |
| Recorded-tick mode / back | Discarded | 2,579 | 278,829 | 0.924940% |
| Recorded-tick mode / forward | Absent | 2 | 93,388 | 0.002142% |
| Recorded-tick mode / forward | Discarded | 2,611 | 93,388 | 2.795862% |
Shares are calculated against each segment’s minute-bar count rather than calendar time, and absent and discarded counts are kept separate because overlap is not established. Even though the recorded-tick back report displays History Quality as “99% real ticks” and the forward report displays “100% real ticks”, neither label proves complete recorded coverage: both journals document generated replacements, mismatched tick prices and tick volumes, and substitution of bid prices for last prices.
Fixed inputs used in the worked example
Every segment in the worked example used the four identical Moving Average sample inputs listed below.
| Input | Value |
|---|---|
| MaximumRisk | 0.02 |
| DecreaseFactor | 3 |
| MovingPeriod | 12 |
| MovingShift | 6 |
More info: how the sample opens, sizes and closes trades
The sample averages closing prices and shifts the resulting line. At the start of a new bar, it compares the previous bar with the stored moving-average values. It opens a sell when the price crosses from above to below the average and closes it on the reverse crossing. To choose trade size, it uses the funds available for new trades and the estimated funds the trade would tie up. It reduces size after consecutive losses and respects the instrument’s trade-size limits. The sample uses the MaximumRisk value of 0.02 to calculate trade size. A trade can lose more than 2% of the account. The sample opens each trade without preset prices for cutting a loss or taking a profit.
The saved configurations use no added execution delay, so this example does not measure live slippage in trading or market impact. The tester journals also record market-closed rejections on attempted entries and position closes, meaning the outcomes reflect the trading sessions and order handling of this tester environment rather than every request filling. Save your own symbol specification, commission schedule and execution settings alongside any rerun—matching the preset alone is not enough to reproduce an outcome.
Reading the MetaTrader 5 worked example
The requested full-year tests produced a report for the earlier period and log entries for both periods. The individual reports below came from separate runs of each period. Their balances and execution sequences match the corresponding passes in the journals. The table below shows the fixed date split used across both price models without choosing parameters from outcomes.
| Window | Start, included | End, excluded |
|---|---|---|
| Back | 2025.01.01 | 2025.10.01 |
| Historical forward | 2025.10.01 | 2026.01.01 |
Starts are included and ends are excluded. Each window starts with fresh 10,000.00 EUR capital, and positions are not carried from the back run into the forward run. In both back runs, the tester closed the remaining open position at the end of the test, and those realised losses are included in the results. Because the forward window uses past prices, this split is a historical holdout rather than realtime forward trading.
The table compares four separate runs. It lists the profit or loss after recorded costs (net result), total gains divided by the size of total losses (profit factor), completed trades, individual order executions (deals) and the final account balance. Each completed trade in this example has two deals, and the money amounts are in EUR.
| Model / window | Net (EUR) | Profit factor | Trades | Deals | Final balance (EUR) |
|---|---|---|---|---|---|
| Minute OHLC / back | 452.28 | 1.57 | 194 | 388 | 10,452.28 |
| Minute OHLC / forward | -69.96 | 0.66 | 77 | 154 | 9,930.04 |
| Recorded-tick mode / back | 478.83 | 1.64 | 201 | 402 | 10,478.83 |
| Recorded-tick mode / forward | -151.70 | 0.46 | 87 | 174 | 9,848.30 |
Both models gained in the back window and lost in the historical forward window, and recorded-tick mode posted both a larger back gain (478.83 EUR versus 452.28 EUR) and a larger forward loss (-151.70 EUR versus -69.96 EUR). Those differences show sensitivity to price-modelling detail with unchanged inputs; they do not identify a superior model or establish an expectation of profit. Because each segment resets capital, the table compares separate tests rather than one continuous return series, and each net result already includes the report’s charged commission and overnight holding charges or credits (detailed as swap in the cost table below).
Trading costs recorded in the reports
The table shows how the sum of deal profits and losses, commission and charges or credits for holding trades across sessions (swap) add up to each run’s net result in EUR.
| Model / window | Deal profit (EUR) | Commission (EUR) | Swap (EUR) | Net (EUR) |
|---|---|---|---|---|
| Minute OHLC / back | 467.32 | 0.00 | -15.04 | 452.28 |
| Minute OHLC / forward | -63.86 | 0.00 | -6.10 | -69.96 |
| Recorded-tick mode / back | 494.69 | 0.00 | -15.86 | 478.83 |
| Recorded-tick mode / forward | -147.61 | 0.00 | -4.09 | -151.70 |
Deal profit plus charged swap equals the net result in every row, while commission is recorded as 0.00 EUR. Spread is embedded in execution prices rather than subtracted a second time, and the MT5 report carries no separate fee column. These figures describe the saved tests only; they do not establish an effective broker commission schedule, a measured spread series or future trading costs.
The chart below compares the four net results in EUR after recorded commission and swap across the back and historical forward windows.

Why the winning-trade count is uncertain
The recorded-tick forward report lists 21 profit trades (24.14%) and 66 loss trades (75.86%). Inspecting the displayed deal list shows 20 strictly positive trades, 66 negative trades and 1 zero-result trade. Counting that zero-result trade with profitable trades reproduces the report’s count of 21. Because the displayed amounts do not distinguish inclusive counting from hidden precision, keep the report count and the positive-only count separate; net profit and profit factor are unaffected.
Balance curves from the four separate runs
The four native MetaTrader 5 tester charts below show the realised balance curve for each independent run, plotted against trade count on the horizontal axis and EUR account balance on the vertical axis. Each curve starts at 10,000.00 EUR and tracks its own balance history.




One completed trade in both models
This example compares the recorded prices and profits for a short EURUSD trade, where the program sells first and buys back to close. Both runs sold 0.06 lots (standard forex trade-size units) on 2025.01.02 at 12:00:00 and bought to close on 2025.01.03 at 08:00:00.
| Model | Sell time | Sell price (USD per EUR) | Buy-to-close time | Buy-to-close price (USD per EUR) |
|---|---|---|---|---|
| Minute OHLC | 2025.01.02 12:00:00 | 1.03512 | 2025.01.03 08:00:00 | 1.02723 |
| Recorded-tick mode | 2025.01.02 12:00:00 | 1.03512 | 2025.01.03 08:00:00 | 1.02725 |
Under Minute OHLC, the exit shows deal profit of 46.09 EUR and swap of 0.11 EUR with zero commission on entry and exit, netting 46.20 EUR. Under recorded-tick mode (buy-to-close price 1.02725 versus 1.02723), the exit shows deal profit of 45.97 EUR and swap of 0.11 EUR with zero commission on entry and exit, netting 46.08 EUR. Both pairs are reported executions and charged amounts, not a reconstruction of the signal. The journal links each buy that closed the full trade to the original sell. The hourly times are consistent with the sample checking its rules at the start of a new bar. Reconstructing the exact decision and trade size would also require the bar prices, stored moving-average values, funds available for new trades and the instrument’s trade-size limits at those moments.
How to run a strategy report in TradingView
According to TradingView’s documentation, adding a Pine strategy (a strategy script written in TradingView’s Pine language) on Supercharts (TradingView’s main charting interface) produces a Strategy Report beneath the chart; older help pages also refer to this pane as the Strategy Tester. The steps below describe TradingView’s documented controls, while the worked historical results above come from MT5. For building a Pine strategy on TradingView, see the Pine Script strategy guide.
- Use Symbol Search to select
EURUSDand record the data provider. Choose an hourly timeframe and standard candles, and note the chart timezone—matching symbol names do not make data feeds identical. - Open Indicators, then Technicals and Strategies, and add your chosen Pine strategy. Record the script name, version and inputs before reading its performance.
- Check the report’s date coverage. Standard chart history depends on the symbol, timeframe and plan. Custom date intervals can use Deep Backtesting where plan access and history allow; Deep Backtesting outputs appear in the report rather than on the chart, and a date selector cannot create missing history.
- In the strategy’s Settings and Properties, enter initial capital, currency, order size, commission and slippage. TradingView applies commission when a trade opens and closes. Its slippage setting counts ticks, meaning the smallest price increments for the instrument. The setting is an assumption about the fill price. It does not measure historical buy and sell prices.
- Review the execution and historical-bar settings. TradingView’s default order simulator estimates how the price moved inside a bar from its opening, high, low and closing prices. Bar Magnifier uses shorter price bars for more detail. MT5 recorded-tick testing uses saved price updates where available.
- Read total profit and loss (P&L), profit factor, drawdown and individual closed trades, keeping realised P&L separate from open P&L. Before reconciling exported rows to summary totals, check whether early records were trimmed and whether the export covers the exact same interval.
- Before comparing revised inputs, declare every change upfront, keep the evaluation window fixed and archive every run. Compare signals on past bars with signals as new prices arrive. Recalculation or changing historical inputs can make past signals or values change when you reload the chart. Check any requests for data from longer bars to see whether a decision can use prices that were still changing or unavailable at the time.
Keep Bar Replay and Replay Trading separate from Pine strategy reports and realtime Paper Trading. Bar Replay reveals past candles for visual review and Replay Trading supports manual historical trading; advancing through past bars is not realtime observation of fresh market data arriving after a strategy is frozen.
How to read the numbers in a test report
Reading a single headline profit number hides how the strategy behaved along the way. Check four core measures together:
- Net result: total trading outcome after the costs represented in the report. Check every deal row, including entry-side costs and separate charges, exclude deposits or withdrawals, and reconcile net result against the change in balance.
- Profit factor: gross profit divided by the size of gross loss. If a sample has zero gross loss, division does not produce a finite ratio—do not invent one. Read trade count and loss sizes alongside profit factor rather than treating any single number as a universal pass mark.
- Trades and deals: in the MT5 sample above, one completed entry and exit equals one trade while each individual execution is one deal. Other execution patterns require their own grouping rules, and a high proportion of winning trades alone says little about the size of losses.
- Balance drawdown versus equity drawdown: A drawdown is a fall from a previous peak. Maximum drawdown is the largest such fall on the chosen measure. Balance follows realised results, and equity also reflects gains and losses on trades still open.
The table below compares maximum balance drawdown and native report equity drawdown across all four separate MT5 segment runs (all money amounts in EUR).
| Model / window | Max balance drop (EUR) | At that balance drop (%) | Max equity drop (EUR) | At that equity drop (%) |
|---|---|---|---|---|
| Minute OHLC / back | 128.12 | 1.25 | 205.08 | 1.99 |
| Minute OHLC / forward | 77.64 | 0.78 | 87.47 | 0.87 |
| Recorded-tick mode / back | 128.72 | 1.25 | 204.91 | 1.98 |
| Recorded-tick mode / forward | 153.56 | 1.54 | 166.08 | 1.66 |
Closed trades alone cannot recreate the intratrade equity path, so keep native equity drawdown figures labelled as report values. Each percentage in the table is for the euro drop beside it. The largest percentage drop can occur at another point. Always verify actual date coverage before interpreting any number: because the back and forward runs restart capital at 10,000.00 EUR, never add their drawdown percentages together or read a back-window curve as a full-year result.
Checks to run after your first test
Leave your original baseline run untouched and record follow-up checks as separate experiments (the worked example above covers one instrument and one fixed split only, not the follow-up methods below):
- Test input sensitivity cleanly: predeclare a small set of parameter changes, say exactly which assumption changes in each comparison, and archive every run—including losses and runs with zero trades.
- Check different market conditions: evaluate rising, falling, range-bound and volatile periods on separately declared date windows, recording why each window was selected before viewing outcomes.
- Separate data errors from real extremes: investigate apparent outliers and document any data correction, but keep valid extreme price moves in the baseline—deleting an inconvenient loss changes the question being tested.
- Stress-test cost and execution assumptions: rerun the baseline with documented changes in cost and execution settings and save those settings beside each report. More favourable settings are never proof that a strategy will obtain them in live trading.
- Archive everything together: store data versions, strategy code, settings, reports and journals in one record. When reruns differ, compare inputs, history coverage, feed revisions, timestamps and execution settings before attributing the difference to the quality of the strategy.
More info: other ways to test trading rules
The worked example used one program and fixed settings. Rolling walk-forward analysis selects settings on an earlier period, tests them on a later period and repeats as the periods advance. A Monte Carlo simulation can reorder trade outcomes over repeated runs to show a range of possible results. To test several strategies together, choose the strategies, collect the relevant price history, run the tests and analyse the results.
Seven common mistakes that mislead test results
- Repeatedly selecting on the holdout. Tuning inputs until the holdout looks attractive turns evaluation into further fitting. Preserve failed trials and declare a fresh holdout window before modifying the strategy.
- Assuming price detail that is absent. Missing ticks and coarse bar modelling can alter order fills and stop triggers. Read the tester journal alongside the summary report.
- Allowing future information into past decisions. Repainting indicators (indicators whose past signals or values change on recalculation or chart reload), still-changing higher-timeframe values and inappropriate lookahead (code using future bar data in earlier decisions) can make historical results differ from what happens as new prices arrive. Inspect the code and recalculation rules rather than trusting the curve alone.
- Using synthetic charts without checking fills. TradingView’s strategy documentation recommends standard chart prices for realistic testing; synthetic candle types and inferred intrabar paths can distort simulated fills.
- Ignoring costs and fill quality. Spread, commission, financing, slippage and market impact are separate items, and a simulated fill is not proof of live liquidity.
- Expecting platforms to agree automatically. Different feeds, code implementations, bar construction and execution assumptions can produce different results. The TradingView steps above explain how to run a report. The worked results come from the separate MT5 example.
- Equating automation with human discipline. An automated test does not prove a trader will follow every rule through a losing period. Fear, greed and overconfidence can alter actual decisions and must be kept separate from historical arithmetic.
Sources: Saved MetaTrader 5 reports and tester journals for the EURUSD example. Platform instructions come from MetaQuotes (MetaTrader 5 Help: Strategy Testing, Real and Generated Ticks, Testing Report, Strategy Optimization, Testing Features, Platform Start, Hot Keys; Moving Average sample expert advisor); TradingView (Strategy Report: How to start, Strategy properties, How Deep Backtesting works, Historical intraday data: bars and limits explained, Symbol Search, How to change the time frame quickly, Bar Replay, Learn to trade on historical data, What are strategies, backtesting and forward testing, and Pine Script documentation on Strategies, Repainting and Limitations).
Frequently asked questions about testing trading strategies
How do the MetaTrader 5 modelling modes differ?
MetaTrader 5 offers four modes with different levels of price detail: Every tick generates ticks from minute bars, Every tick based on real ticks uses recorded ticks where available (with generated replacements possible where recorded ticks are absent or discarded and suitable minute data exists), Minute OHLC uses minute open, high, low and close values, and Open prices only evaluates rules at bar openings. Always read the tester journal before assuming full tick coverage.
Why can two tests of the same currency pair give different results?
Even when the symbol name matches, differences in data feed, exact date boundaries, strategy version, input parameters, spread history and execution model can change the fills and outcomes. Record all of those details before comparing two reports across runs or platforms.
Where do spread, commission and slippage enter a strategy test?
In MetaTrader 5, spread reflects the price history and modelling mode while advanced tester settings handle predefined or custom commission schedules and execution assumptions; in TradingView, commission (applied on entry and exit) and slippage measured in minimum price increments are entered in Strategy Properties. Always inspect the charged totals in the finished report rather than assuming costs were applied.
What is the difference between net result, profit factor and drawdown?
Net result is profit or loss after represented report costs, profit factor divides gross profit by the size of gross loss, and drawdown measures a drop from a peak in balance or equity. Equity also counts gains and losses on trades that are still open. None of the three is a universal pass threshold on its own; read them alongside trade count and actual date coverage.
Is a historical forward window the same as realtime forward testing?
No. A historical holdout or forward window still uses past data, whereas realtime forward observation begins after the rules are frozen and records subsequent signals and outcomes as new market data arrives.
Does TradingView Bar Replay automatically test a Pine strategy?
No—keep those tools separate. A Pine strategy generates its own Strategy Report on Supercharts, while Bar Replay reveals historical candles for manual inspection and Replay Trading supports manual historical trading, neither of which proves automated strategy execution or realtime observation.
What should I save so another person can reproduce my test?
Archive the exact strategy source, executable and preset, platform version, data provider and symbol specification, timeframe, timezone and warmup details, declared back and holdout dates, capital and sizing rules, cost and execution assumptions, plus the finished reports, charts and journals. Configuration files alone do not preserve every part of a test.




