Strategy Tester: What It Does, the Main Platforms and What to Check
What a strategy tester simulates, how TradingView and MetaTrader 5 fill orders on past bars, what TrendSpider offers, the settings to change before trusting a report, a checklist for judging any tester, and a test on our own price data of the trap behind every optimize button.

On this page
A strategy tester is the part of a trading platform that runs a rule, written as code or set up in a form, over historical prices and shows the trades it would have produced: entries, exits, profit and loss, drawdown and statistics such as the win rate. It answers one question, what would this rule have done in the past, and only under the assumptions it was given. This page covers the tool itself: how the main testers work and which settings matter. The method, from writing the rule to the biases that inflate a result, is in our guide to backtesting.
Where each order type sits relative to the price

What a strategy tester simulates
The tester reads the bars one at a time. At each bar, the rule decides whether to place, change or cancel orders, and a simulated broker decides whether and at what price they fill: a market order at the next available price, a limit order at its price or better, a stop order once the price trades through it. The fill is where the simulation departs from reality. A bar records four prices, the open, high, low and close, but not the order in which they came. On a daily bar where both a stop and a target were within reach, a tester that only knows the four prices has to guess which one came first. A finer mode, minute bars or real ticks, removes much of that guess.
Inside one bar: which order fills first

TradingView documents its default guess: when the open is closer to the high, its broker emulator assumes the price went open, high, low, close; when the open is closer to the low, open, low, high, close. It also assumes no gaps inside a bar. On a wide bar that touched both a stop and a target, that rule alone decides whether the test books a win or a loss, which is why the bar detail setting below matters most for strategies with tight stops and targets.
The main strategy testers
| Platform | How it runs a test |
|---|---|
| TradingView (Pine Script strategies) | A broker emulator that uses only the chart's data by default, assuming the price went from the open to the nearer of the high or the low, then to the other, then to the close. An order created on a bar's close fills at the earliest at the open of the next bar. Premium and Ultimate plans can use more detailed intrabar data. |
| MetaTrader 5 Strategy Tester | Tests Expert Advisors with ticks generated or recorded in one of four modes, described below, and can insert a network delay between a trade request and its execution. |
| TrendSpider Strategy Tester | Strategies built from entry and exit conditions, built-in scripts or saved scripts, without coding, according to the platform. |
TradingView keeps detailed data for up to the latest 9,000 trades, and its Deep Backtesting, on Premium and higher plans, runs the strategy on the symbol's entire available dataset. MetaTrader 5 adds optimization over parameter sets, forward testing on a part of the period kept apart, multi-currency tests, visual testing, remote agents and the MQL5 Cloud Network. On TrendSpider, long and short strategies cannot be tested at the same time, and an AI Explain button comments on the results (more in our TrendSpider review).
Setting up the TradingView strategy tester
These settings are in the strategy's "Settings/Properties" tab, and a script can set its own defaults in strategy(). The defaults are those of TradingView's Pine Script documentation.
| Setting and default | Why it matters |
|---|---|
| Commission: none | A flat fee per order, a fee per contract or share, or a percentage of the trade value; without it every trade is free. |
| Slippage: 0 ticks | Each order fills that many ticks beyond the intended price, against the trader. The documentation warns that too much slippage can fill orders outside the candle and make results unrealistically worse. |
| Order execution delay: an order created on a bar's close fills at the next bar's open | Removing the delay fills at the same close. TradingView's FAQ notes that, live, an order sent at the close of a session's last bar fills only on the next trading day, so backtest and live results can differ. |
| Bar detalization: chart data only | The "High" option, on Premium and Ultimate plans, reads bars from a lower timeframe to place fills inside each bar more precisely. |
| Limit order execution: fills as soon as the price touches the limit | Requiring a move of one tick or more beyond the limit is closer to real trading, where a touched limit does not always fill. |
| Heikin Ashi mode: chart bars | On Heikin Ashi charts, fills at actual prices instead of computed ones; results on non-standard charts do not reflect actual market conditions by default. |
In the strategy() declaration, the matching parameters are commission_type and commission_value, slippage, process_orders_on_close, use_bar_magnifier, backtest_fill_limits_assumption and fill_orders_on_standard_ohlc.
Setting up the MetaTrader 5 strategy tester
The MetaTrader 5 tester runs Expert Advisors, the platform's trading programs; its tick generation mode decides how much of the path inside each bar the test sees. The documentation lists five modes; four of them replay prices:
| Mode | What the documentation says |
|---|---|
| Every tick | The most accurate but the slowest of the simulated modes: all ticks are simulated. |
| Every tick based on real ticks | Uses the real ticks of the instrument accumulated by brokers, with no simulation; the first download can take a long time. |
| 1 minute OHLC | Only the open, high, low and close of each minute bar are emulated. |
| Open prices only | Only the open price of each bar is used. |
| Math calculations | No price history and no ticks: the tester only calls the program's initialization, test and shutdown functions, for mathematical calculations that need a parameter search, not for testing trades. |
Three other settings change the result. The execution delay can be set to none, which the documentation calls "ideal" conditions, to a fixed delay such as the measured ping to the trade server, or to a random delay, 0 to 8 seconds 90% of the time and 9 to 18 seconds otherwise. The forward option splits the period into a back test, used for tuning, and a forward test, a half, a third, a quarter or a custom part of the period, always taken at its end, on which the chosen parameters are checked. Profit calculated in pips speeds up a test but leaves out swaps, commissions and margin control, and the documentation advises using it only for a rough estimate. The tester also loads at least 100 bars of history before the start date, so a test that starts close to the beginning of the data is shifted later.
A test period split into a back test and a forward test

What to check in any strategy tester
- When orders fill. An order triggered by a bar's close should fill on the next bar at the earliest; a test that fills at the signal bar's close knows that close in advance.
- What it assumes inside a bar. Find out how the tester orders the high and the low, and whether a finer mode, lower timeframe bars or real ticks, is available.
- Costs. Commissions, spreads and slippage are often zero by default; set them, then rerun with higher costs than you expect.
- Limit order fills. A limit touched by one tick is not always filled in real trading.
- Chart type. Heikin Ashi, Renko and other non-standard charts show computed prices; run the test on standard candles.
- Data. How far back the history goes, and whether it includes delisted securities. A test on today's list of stocks leaves out the companies that failed: in a study of US common stock funds, published in 1996, Elton, Gruber and Blake measured the gap between the surviving funds and all funds at about 0.9% a year (working paper version).
- Out-of-sample testing. A forward period, or a part of the data kept out of the tuning, is the only part of a report that was not fitted. Our test below shows how much a tuned result can lose there.
- The report. The number of trades, the largest drawdown and the list of trades, not just the net profit.
When an order triggered at the close can fill

The pitfalls behind these checks, look-ahead bias, overfitting, selection bias and survivorship bias, are explained with a worked example in our backtesting guide. TradingView's documentation adds that an overfit strategy often fails on new, unseen data, and that slippage is dynamic and unpredictable, impossible to simulate precisely.
The trap we measured: tuning the parameters
MetaTrader 5 runs an optimization over sets of parameters for you, and on any tester you can change the inputs and rerun until the report looks good. The top result always looks strong, because it is the best of many tries. The question no report answers is how much of it was a real edge and how much was luck in the tested years. We measured it on our daily price data with one of the most common rules, a moving average crossover.
The rule buys when a fast simple moving average closes above a slow one, and sells and stays out when it closes below; there is no short selling. The fast average takes the lengths 5, 10, 15, 20, 30, 40, 50 and the slow one 20, 30, 50, 75, 100, 150, 200, the fast always shorter than the slow: 41 pairs in all. An order decided at a close fills at the next open, and every buy and every sell pays half of a round trip cost of 0.05% on SPY, 0.03% on EUR/USD and 0.20% on Bitcoin. Returns are prices only, with no dividends and no interest on cash, for the rule and for buy and hold alike.
The test is a walk-forward analysis. Each round picks the pair with the highest annual return after costs over 3 calendar years, then replays it unchanged on the next calendar year, which the choice never saw. The window then moves forward one year and the choice starts over. That gives 29 unseen years on SPY, from 1997 to 2025, 10 on EUR/USD and 4 on Bitcoin. All these settings were fixed before the first run, and none was changed after.
Best moving-average crossover: tuned years against the next, unseen year

- 3 tuning years
- Next year, unseen
On SPY, the tuned winner beat buy and hold by +2.4% a year, on average, over its tuning years. In the following year it trailed buy and hold by 4.5% a year. On Bitcoin the swing was larger: an edge of +26.3% a year while tuning, then a shortfall of 25.8% a year on new data. Only EUR/USD kept part of its edge, +0.7% a year out of +3.8%, about 17.5% of it, over 10 years only.
The random walk rows are the control. Those prices have the daily volatility of each market and no trend at all, so no pair of averages can have a real edge on them. The optimizer found one anyway: +7.5% a year above buy and hold on prices as volatile as SPY, more than on SPY itself, and +30.2% a year on prices as volatile as Bitcoin. In the next year it was gone. An in-sample edge of a few percent a year is what tuning finds in pure noise, so a report that shows one proves nothing by itself.
Where the tuned winner ranked the following year

- Real prices
- Random walk, same volatility (median of 20)
If the tuning had found something real, the winner would stay near the top the next year. It did not. Across all 43 unseen years, it beat on average 52.9% of the other pairs, where a pair drawn at random beats 50% on average, and it did better than the median pair in 21 of the 43 years. The rank correlation between the tuning years and the next year, over the 41 pairs, averaged 0.02, close to zero: a good rank in the past said almost nothing about the next year. The winner also kept changing: on SPY, the best pair was a different one from one round to the next 22 times out of 28.
Chained together, the unseen years give what a trader who followed the procedure would have earned. On SPY it made 6.2% a year from 1997 to 2025, against 9.8% for buy and hold. Being out of the market often, it had a smaller worst drawdown, 33.7% against 55.2%. On Bitcoin it made 14.3% a year against 17.4%, and on EUR/USD 1.6% against 0.8%.
The chart pattern figures on this site come from our own test bench, built with these checks in mind: a pattern is recorded on the bar where a trader could have seen it, and everything measured afterward starts on the next bar. One limit remains: on stocks, most companies that were delisted after a bankruptcy or a merger are missing from our data, a serious survivorship bias that we have not measured; stock results lean bullish, and the methodology says so. The full method is in our methodology.
More guides are in technical analysis.
Frequently asked questions
What is a strategy tester?
A tool that runs a trading rule over historical prices and reports the trades it would have made, with their profit, loss and drawdown. TradingView, MetaTrader 5 and TrendSpider all include one.
Is the TradingView strategy tester accurate?
It is as accurate as its settings. By default it uses only the chart's bars, applies no commission and no slippage, and fills limit orders as soon as the price touches them. Setting costs, using the next bar's open and, on Premium and Ultimate plans, setting bar detalization to High make it closer to real trading.
Which MetaTrader 5 testing mode should I use?
The MetaTrader 5 documentation calls Every tick the most accurate simulated mode and says Every tick based on real ticks, which replays the ticks recorded by brokers, provides conditions close to real ones; the first download of those ticks can take a long time. Open prices only is the fastest and suits only rules that act on the open of each bar. The fifth mode, math calculations, uses no prices at all.
Can TrendSpider backtest without coding?
Yes, according to the platform: strategies are built from entry and exit conditions or from built-in and saved scripts. Long and short strategies cannot be tested at the same time.
What is the difference between backtesting and forward testing?
A backtest runs on past data that was available while the rule was designed. A forward test runs on data the rule has never seen, either a part of history kept apart, as in MetaTrader 5's forward option, or new data as it arrives. Our backtesting guide covers both.
Which strategy tester should I use?
The one that runs on the market and data you trade, lets you set costs and slippage, fills orders at prices you could have obtained and lets you test outside the tuning sample. Check how it handles fills inside a bar before trusting its results.
Does optimizing a strategy in a strategy tester work?
Not by itself. On our daily data, we tuned 41 moving-average crossover pairs over 3 years and replayed the best one on the next year, 43 times on SPY, EUR/USD and Bitcoin. The winner beat on average 52.9% of the other pairs the following year, close to the 50% of a random pick, and the same tuning found a sizable in-sample edge on random prices with no trend. Judge a rule only on data kept out of the search.
Sources
- TradingView, Pine Script User Manual, Strategies
- TradingView, Pine Script User Manual, FAQ: Strategies
- MetaTrader 5 Help, Strategy Testing
- TrendSpider Help, What is the Strategy Tester
- Elton, Gruber and Blake, Survivor Bias and Mutual Fund Performance, Review of Financial Studies 9(4), 1996
- Elton, Gruber and Blake, Survivorship Bias and Mutual Fund Performance, NYU working paper, revised March 1995
