0%
BASICS

How to Backtest a Strategy Before You Automate It

Heads up: some links below are affiliate links. If you sign up through them we may earn a commission at no extra cost to you - it never changes what we recommend.

Short answer

Backtest by writing exact rules, running them over enough trades to mean something, then checking how your platform actually filled those orders. The last step is the one people skip. TradingView's own manual says the tester assumes how price moved inside each bar rather than knowing it.

Rather run something already tested?

The LPFT Copilot runs a rules-based method on your own Tradovate account with the risk limits built in, so you are not betting an account on your first backtest. Start a 7-day free trial.

Start your 7-day free trial

What a backtest is for, and what it is not

A backtest answers one narrow question: if these exact rules had run over this exact history, what would have happened? That is genuinely useful. It filters out ideas that never worked, it shows you the shape of the drawdowns you would have had to sit through, and it forces you to state your rules precisely enough for a computer to follow them. That last benefit is underrated and it arrives before you run anything.

What a backtest is not is evidence that a strategy will work, and it is definitely not evidence that an automated version of it will fill the same way. Between the equity curve on your screen and a live order sitting in an exchange queue there are several assumptions, and most traders never find out what they are.

The one-line version

A backtest tells you whether the idea was ever sane. It cannot tell you whether your fills were realistic, and it will never tell you that on its own.

The five steps, done properly

None of this needs code. It needs you to be specific and a little stubborn.

  1. Write the rules as sentences first. Entry, exit, stop, position size, and the conditions under which you do not trade at all. If any sentence contains "usually" or "if it looks right," you are not testing a strategy yet, you are testing your mood.
  2. Pick the data honestly. Test the actual contract and session you intend to trade. A result from a different instrument, or from a period that happened to trend in one direction, is a story rather than a test.
  3. Run enough trades that noise cannot explain the result. A handful of winners proves nothing. You want a sample where one exceptional trade removed from the set does not change your conclusion, and it is worth literally checking that by deleting the best trade and looking again.
  4. Include costs. Commission, exchange fees and an allowance for slippage. A strategy that is profitable only before costs is not a strategy, and micro contracts make this worse because the fees are a larger share of a smaller tick value.
  5. Then, and only then, look at the equity curve. Looking first is how people end up tuning parameters until the picture is pretty, which is the failure mode covered below.

If you have not decided whether a machine should be running these rules at all, work through manual versus automated trading before you spend a weekend on this.

What TradingView's own manual admits about your backtest

Four documented warnings about the accuracy of a TradingView strategy backtest
Three of these four warnings are published by TradingView about its own tester.

This is the part almost no backtesting guide covers, and it comes from the platform itself rather than from a sceptic on a forum. TradingView documents how its broker emulator decides whether your order would have filled, and once you read it you cannot unread it.

It guesses the path through every bar

The emulator does not know how price moved inside a historical bar, so it infers it. In their words, if the opening price of a bar is closer to the high than to the low, the emulator assumes the market moved open, then high, then low, then close, and the mirror assumption applies when the open sits nearer the low. It also assumes no gaps exist within bars and treats any price in the range as valid for filling a pending order.

For a strategy with a stop and a target that could both be hit inside one bar, that guess is the entire result. Change the assumed order and a winner becomes a loser.

It can see prices your live bot could not

TradingView is explicit about this one. During the extra script execution after an order fills, the script has access to the confirmed open, high, low and close values for the historical bar, but those values would not be available in the real world until the bar closing time. That is a look into the future that no live system gets, and it quietly inflates results.

Renko and Heikin Ashi backtests are not market results

Their documentation states that non-standard chart types are not suited for strategy backtesting or automated trading systems execution, because the prices and time intervals do not match market prices and times. On Renko specifically they warn that results are calculated using synthetic prices which most likely do not reflect the actual order fills you would get if you were trading for real. If your beautiful equity curve came off a Renko chart, that is the first thing to check.

The fix costs money, and it is worth knowing why

Bar Magnifier pulls open, high, low and close prices from a lower timeframe so the emulator has more ticks to fill from instead of assuming the path. TradingView lists it, and deep backtesting, on the Premium and Ultimate plans only. Webhook alerts, which you need later to actually automate anything, start one tier lower at Essential.

Need intrabar precision in your backtest?

Bar Magnifier and deep backtesting sit on the Premium and Ultimate plans. If your strategy can hit a stop and a target inside the same bar, this is the difference between a result and a guess.

See TradingView plans

How to catch curve fitting before it costs you

The other way a backtest lies has nothing to do with the platform. It is that you kept adjusting until it looked good. Academic work on this is blunt. Bailey, Borwein, Lopez de Prado and Zhu, writing in the Notices of the American Mathematical Society in 2014, showed that high simulated performance is easy to achieve after trying a relatively small number of strategy configurations, and because nobody reports how many were tried, a reader has no way to judge how overfit a result is.

Their harder finding is the one to remember. Under memory effects, overfitting does not just wash out to zero in live trading, it produces negative expected out-of-sample returns. An over-tuned strategy is worse than no strategy.

For the platform-specific version of this problem, including repainting and why an indicator that looks perfect in hindsight can be worthless live, see why your TradingView strategy backtest lies to you.

Crossing from backtest to automation

A backtest that survives all of the above has earned one thing: permission to be tested for real. It has not earned an account. The order of operations from here is not negotiable if you would like to keep your money.

  1. Re-run it as a clean test with costs and no further tweaks. No adjustments allowed at this stage. You are measuring, not improving.
  2. Run it forward on simulated fills and compare what actually happens against what the backtest expected for the same period.
  3. Run one micro contract live and compare again. This is where the assumptions above stop being theoretical, because now a real order meets a real queue.
  4. Only then consider size. And only if the three sets of numbers broadly agree.

Steps two and three are where most of the surprises live, and they deserve their own treatment. We cover exactly what a simulated account can and cannot prove in paper trading versus live bot testing. If you are still working out what the automation layer even does with your rules, how trading bots work is the plain-English version.

Last thing, and it matters more than any technique here. Futures carry a substantial risk of loss, and a backtest is the cheapest possible way to find out an idea does not work. Let it do that job. Killing a strategy on your laptop costs nothing, which makes a failed backtest a good outcome rather than a wasted afternoon.

Rather not build any of this?

The LPFT Copilot runs the whole stack for you on Tradovate - start a 7-day free trial and watch it work.

Start your 7-day free trial

Frequently asked questions

Write your entry, exit, stop and sizing rules as exact sentences, run them over historical data for the contract and session you actually trade, include commission and slippage, and use a sample large enough that removing the single best trade does not change your conclusion. Then check how your platform decided those orders filled.

It is an approximation, and TradingView documents why. The broker emulator infers how price moved inside each historical bar from the position of the open, assumes no gaps exist within a bar, and treats any price in the range as fillable. Bar Magnifier improves this by pulling lower-timeframe prices, and it is listed on the Premium and Ultimate plans.

There is no single magic number, and anyone quoting one precisely is guessing. A practical test is whether your conclusion survives the removal of your single best trade. If deleting one winner turns a profitable system unprofitable, your sample is too small regardless of its size.

You can run one, but TradingView states that non-standard chart types are not suited for strategy backtesting or automated trading systems execution, because the prices and time intervals do not match market prices and times. On Renko they add that results use synthetic prices that most likely do not reflect actual fills.

Curve fitting is tuning a strategy until it describes past data closely rather than capturing anything durable. Research published in the Notices of the American Mathematical Society in 2014 found that strong simulated performance is easy to reach after a relatively small number of configurations, and that overfitting can produce negative expected returns out of sample.

No. A backtest establishes that an idea was not obviously broken in the past. Before real size, run the same rules forward on simulated fills, then on a single micro contract live, and compare all three sets of results. Futures trading carries a substantial risk of loss.

Eli Y., founder of Live Prop Firm Trading

Eli Y.

Founder · Live Prop Firm Trading

Eli builds and runs rules-based automated futures systems on TradingView and Tradovate, and helps traders take emotion out of the screen. He writes about futures automation, prop-firm evaluations, and the tools that connect them - plainly, and without hype.

Risk disclosure: Trading futures involves substantial risk of loss and is not suitable for everyone. This article is educational content only and is not financial advice or a recommendation to trade. Past performance is not indicative of future results. Some links are affiliate links.

Free · Subscribers hear it first · Unsubscribe anytime

Hear about every sale and market shift first.

Flash sales and prop-firm promo codes before they go public, a heads-up before the big market days (CPI, FOMC, earnings weeks), and the weekly results recap from the desk that actually trades this. Free, straight to your inbox.