Tools / Strategy backtester
Strategy backtester
Test a trading strategy on years of daily prices before you risk money on it. Pick any coin, currency pair, precious metal, share, oil, copper or US index fund, choose one of ten strategy templates or build rules of your own, and read the full report: net profit, yearly growth, deepest fall, win rate, profit factor, Sharpe ratio and every trade. Free, with nothing to sign up for.
Set up a test
Moving average crossover on Gold
Between 5 Jan 1999 and 26 Nov 2026, $10,000.00 grew to $81,055.65: a gain of 710.56% over 18 trades. That is +7.79% a year, compounded. Buying and holding over the same days gained 1,163.04%. 18 trades are too few to tell skill from luck.
- Net profit
- +710.56%
- +$71,055.65
- Growth a year (CAGR)
- +7.79%
- Deepest fall
- −37.52%
- 6 Sept 2011 – 11 Jul 2017
- Trades
- 18
- Win rate
- 50.0%
- 9 won, 9 lost
- Profit factor
- 4.92
- Buy and hold
- +1,163.04%
- $126,303.66
- Against buy and hold
- −452.48%
All the figures
| Starting capital | $10,000.00 |
|---|---|
| Final equity | $81,055.65 |
| Gross profit | $89,179.24 |
| Gross loss | −$18,123.60 |
| Average trade | +$3,947.54 (+15.98%) |
| Average win | +$9,908.80 |
| Average loss | −$2,013.73 |
| Payoff ratio | 4.92 |
| Largest winning trade | +$40,389.90 (+99.32%) |
| Largest losing trade | −$4,499.63 (−10.80%) |
| Longest winning streak | 5 |
| Longest losing streak | 5 |
| Average time in a trade | 273.9 days |
| Average time in a winning trade | 448.6 days |
| Average time in a losing trade | 99.3 days |
| Time in the market | 67.9% |
| Sharpe ratio (monthly, TradingView’s method) | 0.14 |
| Sharpe ratio, annualised (× √12) | 0.47 |
| Sortino ratio (monthly, TradingView’s method) | 0.24 |
| Sortino ratio, annualised (× √12) | 0.83 |
| Calmar ratio | 0.21 |
| Commission paid | $0.00 |
Equity against buy and hold
the strategy buy and hold
Fall from the last high
Price, with each entry and exit
entry exit
The trades
| No. | Side | Entry | Exit | Days | Return | Profit | Closed by | Equity |
|---|---|---|---|---|---|---|---|---|
| 18 | Long | 6 Dec 2023 2,028.72 | 29 Jun 2026 4,043.68 | 668 | +99.32% | +$40,389.90 | Signal | $81,055.65 |
| 17 | Long | 13 Jan 2023 1,891.99 | 29 Sept 2023 1,880.63 | 185 | −0.60% | −$245.59 | Signal | $40,665.75 |
| 16 | Long | 15 Feb 2022 1,863.58 | 7 Jul 2022 1,751.55 | 102 | −6.01% | −$2,616.72 | Signal | $40,911.34 |
| 15 | Long | 3 Dec 2021 1,773.09 | 28 Jan 2022 1,806.91 | 40 | +1.91% | +$814.74 | Signal | $43,528.06 |
| 14 | Long | 28 Jun 2021 1,780.70 | 11 Aug 2021 1,731.98 | 32 | −2.74% | −$1,201.57 | Signal | $42,713.32 |
| 13 | Long | 18 Jan 2019 1,290.71 | 18 Feb 2021 1,785.10 | 544 | +38.30% | +$12,162.33 | Signal | $43,914.89 |
| 12 | Long | 15 May 2017 1,230.62 | 27 Jun 2018 1,257.97 | 292 | +2.22% | +$690.40 | Signal | $31,752.56 |
| 11 | Long | 1 Mar 2016 1,239.68 | 23 Nov 2016 1,209.04 | 191 | −2.47% | −$787.35 | Signal | $31,062.15 |
| 10 | Long | 2 Jul 2014 1,326.47 | 23 Sept 2014 1,217.28 | 59 | −8.23% | −$2,856.99 | Signal | $31,849.50 |
| 9 | Long | 24 Mar 2014 1,332.23 | 4 Jun 2014 1,244.57 | 52 | −6.58% | −$2,444.59 | Signal | $34,706.49 |
| 8 | Long | 21 Sept 2012 1,765.55 | 22 Feb 2013 1,574.81 | 110 | −10.80% | −$4,499.63 | Signal | $37,151.08 |
| 7 | Long | 28 Feb 2012 1,770.30 | 17 Apr 2012 1,655.38 | 35 | −6.49% | −$2,891.39 | Signal | $41,650.71 |
| 6 | Long | 12 Feb 2009 929.5539 | 14 Feb 2012 1,722.75 | 783 | +85.33% | +$20,508.32 | Signal | $44,542.10 |
| 5 | Long | 22 Dec 2006 620.3175 | 3 Sept 2008 800.5445 | 443 | +29.05% | +$5,410.74 | Signal | $24,033.78 |
| 4 | Long | 18 Aug 2005 440.1901 | 23 Oct 2006 594.2348 | 307 | +35.00% | +$4,827.69 | Signal | $18,623.05 |
| 3 | Long | 5 Oct 2004 413.9729 | 1 Jun 2005 415.7864 | 171 | +0.44% | +$60.17 | Signal | $13,795.36 |
| 2 | Long | 30 May 2001 269.6248 | 8 Jun 2004 393.1268 | 789 | +45.81% | +$4,314.95 | Signal | $13,735.19 |
| 1 | Long | 26 Oct 1999 281.3265 | 5 May 2000 265.0162 | 128 | −5.80% | −$579.76 | Signal | $9,420.24 |
This market has one price a day here: signals are filled at the next day’s close, stops are tested against each close, and the ATR is the average close-to-close move.
Daily reference rates published by the European Central Bank and other central banks, compiled by Frankfurter. Reference rates are not prices you could have traded at.
How the test is run
A backtest replays a rule over past prices: it shows what the rule would have done, not what it will do. Every test here follows the same fixed rules, so that two results can be compared.
Fills. A signal is read on a day’s closing price and filled at the next day’s opening price, never on the day that gave it; a signal on the last day makes no trade. Coins, currencies and metals have one price a day here, so their signals are filled at the next day’s close.
Position. One position at a time, with all of the capital in it, so gains and losses compound. Long only unless you choose short, or long and short. A position still open on the last day is closed at that day’s close. A trade’s days are days that have a price: trading days, not calendar days.
Stops. A stop-loss, take-profit or trailing stop is tested against each day’s high and low. If a day opens beyond the level, the fill is the open (a gap), not the level. If one day holds both the stop and the target, the stop is taken: the cautious reading. The trailing stop follows the highest high since the entry, by a percentage or by a multiple of the 14-day ATR. Where there is only one price a day, levels are tested against each close and filled there, and the ATR is the average close-to-close move.
Costs. Each buy and each sell pays the commission and is filled worse than the quoted price by the slippage. Unless you change them: commission 0.10% and slippage 0.05% for crypto, commission 0.05% and slippage 0.05% for shares and funds, commission 0.00% and slippage 0.02% for currencies and metals. Borrowing costs, dividends, interest, spreads wider than the slippage and taxes are not counted.
Buy and hold, the yardstick, buys at the test’s first possible fill, pays no costs and holds to the last day.
What the figures mean
Growth a year (CAGR) is (final ÷ starting capital) to the power of 365 ÷ days, less 1. The deepest fall (maximum drawdown) is the largest drop of the equity from an earlier high, measured on closing values. Profit factor is the winning trades’ total divided by the losing trades’ total. The average trade is the net profit divided by the number of trades.
The Sharpe ratio is worked out as TradingView’s strategy tester does: the average monthly return of the equity less a risk-free 2% a year (a twelfth a month), divided by the standard deviation of the monthly returns. It is a monthly figure; the annualised one multiplies it by the square root of 12. The Sortino ratio divides by the deviation of the months that fell short of the risk-free rate only. The Calmar ratio is growth a year divided by the deepest fall.
What a backtest cannot tell you
Past results do not predict future ones. A rule tuned until it fits the past will usually disappoint afterwards, and a result built on a handful of trades means little: look for dozens. The markets on this site are ones that exist today, so coins and companies that failed are missing (survivorship bias), which flatters any test of buying.
Share prices are adjusted for splits but not for dividends, so a long test of a share that pays dividends understates what a holder earned. Coin history on this site reaches back two years. Currency and metal prices are daily central bank reference rates, not prices anyone could trade at. Short selling is tested without borrowing fees or margin calls.
An estimate for study, not investment advice. Nothing you enter leaves your browser except the address of this page.