How to Backtest a Trading Strategy for Free, With Two Real Examples
Seven steps to backtest a trading strategy without paying for software, shown on two real Bufflo backtests: an MNQ breakout that only broke even, and a QQQ setup that fell apart on a year it never saw.
To backtest a trading strategy, write its rules so exactly that a computer could follow them, replay them over past price data with realistic costs, and judge the trades on net profit, drawdown and how many there were. Then run the same rules, unchanged, on a period you did not use to build them. That last step is the one most traders skip, and it is the one that tells you the most.
This guide walks through each step on two real backtests run in Bufflo, neither of which went to plan. You can follow along free: Bufflo’s Free plan includes 10 backtests a month, and you describe the strategy in plain English instead of writing code.
How to backtest a trading strategy, step by step
Write rules a computer could follow. Every rule needs a number: the entry, the stop, the target, the position size, the hours you trade and the latest time you hold. “Buy strong breakouts” cannot be tested. “Buy the first 5-minute close above the 09:30 candle’s high” can.
Pick the market, timeframe and period. Test the instrument and bar size you actually trade, over a stretch long enough to include different conditions: a trend, a sell-off, a quiet month.
Set your costs before you see any results. Commission, fees and slippage per trade. Decide them first, so a disappointing result does not tempt you to make them smaller.
Keep a period back. Build and adjust the rules on one stretch of history, and leave another untouched until the end.
Run it, then check individual trades. Open a few trades on the chart and confirm each one did what the rules say. A misread rule shows up here, not in the totals.
Read the results that matter. Net P&L after costs, the number of trades, average win against average loss, profit factor and max drawdown. The next section explains each one.
Run the final rules on the period you kept back. Change nothing. If the result holds up, the setup is worth watching live. If it does not, you found out without risking money.
In Bufflo, the first three steps are one message to Bufflo AI. It turns your description into rules grouped as scope, entry, exit, hours, size and costs, and shows them before anything runs, so a misunderstanding gets caught before it costs you a backtest. Asking Bufflo AI to write or change a strategy uses one AI request; running the backtest uses none.
What testable trading rules look like
Most strategies fail the first step: they sound precise until you try to apply them to a chart. Here is the difference, taken from a real opening range breakout request in Bufflo.
| The idea | The testable rule |
|---|---|
| Buy the breakout | Buy the first trade after a completed 5-minute candle closes above the 09:30 candle’s high |
| Only trade sensible ranges | Take the break only when the opening range is between 0.3 and 3 ATR wide (Wilder ATR, 14 bars) |
| Keep the stop tight | Stop at the far side of the range, never more than 2 ATR from entry |
| Let winners run | Once the trade is 1R in profit, move the stop to breakeven, then one R closer for each further full R |
| Don’t hold overnight | No entries after 15:30; close any open position from 15:55 New York time |
| Include costs | Charge $1 per completed round trip for commission and slippage |
How to read backtest results
A backtest report has a dozen numbers. These are the ones that decide whether a strategy is worth more of your time.
| Result | What it tells you | What to check |
|---|---|---|
| Net P&L after costs | What the rules made once every cost is taken out | Compare it with gross P&L: if costs take most of it, the edge is thin |
| Number of trades | How much evidence you have | A few dozen trades can look good by luck; more trades, across different conditions, mean more |
| Win rate | How often trades won | It means little on its own: below, a 26% win rate breaks even and a 57% win rate loses money |
| Average win and average loss | How big winners are next to losers | The win rate you need to break even is 1 ÷ (1 + average win ÷ average loss) |
| Profit factor | Gross wins divided by gross losses, after costs | Above 1 is profitable; barely above 1 leaves no room for worse fills |
| Max drawdown | The deepest fall from a peak in the account | Ask honestly whether you would have kept trading through it |
| Long and short separately | Which side of the market carried the result | A strategy that only works one way may just be riding that period’s trend |
The break-even formula is worth memorising. A strategy whose average win is 2.81 times its average loss needs to win 1 ÷ 3.81, or 26.2%, of its trades to break even. The MNQ example below won 26.3%.
Example 1: an MNQ breakout that only broke even
The rules above ran on Micro E-mini Nasdaq-100 futures (MNQ1!) from 22 November 2025 to 22 November 2026: one contract, $100,000 of starting capital and $1 of costs per round trip.
| Result | All trades | Long only | Short only |
|---|---|---|---|
| Trades | 243 | 130 | 113 |
| Net P&L | +$98 | −$875 | +$972 |
| Profit factor | 1.01 | 0.91 | 1.12 |
| Win rate | 26.3% | 24.6% | 28.3% |
| Max drawdown | −$4,119 | −$1,923 | −$2,835 |
What the numbers say
- Costs decided the result. The trades made $341 before costs and paid $243 in costs. At $2 a round trip instead of $1, the same 243 trades would have lost $145.
- The drawdown was 42 times the final profit. Few traders would have stayed with it through the summer.
- The two sides behaved differently. Shorts made $972 and longs lost $875, and the total hid both.
Dropping the long side looks like an easy fix. It is also exactly the kind of change that has to be tested on a period it was not chosen from, which is what the second example shows.
Example 2: why you test on data you held back
The second strategy is a long-only QQQ opening range breakout: a 15-minute opening range, entry 0.05% above its high before 11:30, a stop at 0.35 of the range width, a 1R target, 0.25% of equity risked per trade and $5 of costs per trade.
Its rules were adjusted and re-run seven times on the same year, 21 November 2025 to 21 November 2026, aiming for a 50% win rate and a profit factor above 1.19. The seven versions made anywhere from $9 to $2,967 on that one year. Then the final rules ran, unchanged, on the year before.
| Result | Year it was tuned on | Year it never saw |
|---|---|---|
| Trades | 163 | 155 |
| Net P&L | +$1,782 | −$101 |
| Win rate | 59.5% | 57.4% |
| Profit factor | 1.20 | 0.99 |
| Average win and loss | +$111 and −$137 | +$85 and −$116 |
| Costs against gross P&L | $815 against $2,597 | $775 against $674 |
| Max drawdown | −$979 | −$1,996 |
The win rate barely moved, which is why win rate alone is a poor guide. What changed was the size of the wins. On the unseen year they were smaller, $5 of costs per trade then took more than the entire gross profit, and the drawdown doubled. Seven rounds of tuning had fitted the rules to one year rather than found something that lasts.
Out-of-sample testing does not need special software. Decide on your test period before you start, tune on everything else, and run the final rules there once.
Backtesting mistakes that make a strategy look better than it is
- Overfitting: changing the rules until the past looks good, as in the QQQ example. Tune as few things as you can, and keep a period aside.
- Look-ahead bias: a rule that uses information nobody had at the time, such as the day’s high deciding a morning entry.
- Survivorship bias: testing only stocks that still trade today leaves out the ones that were delisted, often after falling.
- Costs that are too low: on a thin strategy, the cost per trade decides the result, as the MNQ example shows.
- Too few trades: a handful of big winners can make any rule set look good.
- One kind of market: rules tested only in a steady uptrend have never met a sell-off.
- Guessing what happened inside a bar: when a stop and a target both fall inside the same bar, a bar-by-bar test has to guess which came first. Bufflo replays 5-second candles, so the stop and target fill in the order they actually traded.
Bufflo fills each trade at the traded price that set off the rule. It does not model order queues, short availability or margin, so leave some room in your cost assumption for fills that would have been worse.
Where to backtest a trading strategy for free
- By hand: step through a chart bar by bar and log each trade in a spreadsheet. Free and slow, and hard to keep honest when you can see what comes next.
- In code: open-source Python libraries such as Backtrader and backtesting.py cost nothing, but you write the strategy and find clean intraday data yourself.
- In a charting platform’s strategy tester, such as TradingView’s, where every rule is written in the platform’s scripting language.
- In plain English with Bufflo: describe the strategy, check the rules Bufflo AI writes, and run it on US stocks or futures. The Free plan includes 10 backtests a month with up to 3 months of history. Starter, Trader and Premium raise that to 50, 100 and 200 a month, with 6 months, 2 years and 5 years of history.
Each Bufflo backtest tests one ticker, so to see whether a setup holds up beyond one chart, run it again on others. Free backtesting software compared sets these options side by side, and if you already trade a TradingView indicator, the Pine Script converter runs it on BuffloChart.
Frequently asked questions
How do I backtest a trading strategy for free?
Write the rules down exactly, then replay them on past data: by hand in a spreadsheet, in free code such as Backtrader, in a charting platform’s strategy tester, or in Bufflo, where you describe the rules in plain English. Bufflo’s Free plan includes 10 backtests a month with up to 3 months of history.
Can I backtest futures for free?
Yes. Bufflo backtests US futures such as MNQ, as well as US stocks, on every plan including Free. Each Free backtest covers up to 3 months of history.
How many trades does a backtest need?
There is no fixed number, but a few dozen trades can look good by chance. Aim for enough trades, across different market conditions, that one or two large winners do not decide the result, and confirm it on a period you held back.
What is a good profit factor in a backtest?
Above 1 means winners outweighed losers after costs. A result close to 1, such as 1.01, is fragile: slightly higher costs or worse fills turn it negative. Read it alongside the number of trades and the max drawdown.
What is out-of-sample testing?
Running the final rules, unchanged, on a period you did not use to build or tune them. If a strategy only works on the data it was tuned on, it has probably been fitted to that data.
Does a good backtest mean a strategy will work?
No. A backtest is hypothetical: it shows how fixed rules behaved on past data and cannot account for every real-world factor. Treat a good result as a reason to keep testing, not as a forecast.
Build the workflow you actually want to trade.
Describe your setup in plain English, test the logic, and let Bufflo keep watch when you step away.
Market monitoring and analysis, not a brokerage. Not investment advice. Backtested results do not guarantee future performance. Data availability and refresh rates depend on your plan and market data providers.
Back to all articles