Backtesting Calculator

Backtest a moving average crossover, RSI or MACD rule on your own price CSV against buy and hold, with fees, shorts, drawdown and every trade.

Runs in your browser. Files never leave your device.
One closing price per line, or a CSV export with a Close column. Oldest first; exports listed newest first are put in date order.
Showing example EUR/USD-style daily data.

150 bars · 2026-01-05 to 2026-07-31

Buys when the fast average crosses above the slow one; sells when it crosses back below.

Strategy return+7.37%10,737.35 at the end · buy and hold +6.85%
Closed trades1
Win rate100.0% (1 of 1)
Average trade+7.37%
Maximum drawdown2.10% (buy and hold 3.05%)
Time in the market72.0% of bars
Fees paid20.74
Balance: strategy and buy and hold
  • Strategy
  • Buy and hold
1 trade(s), newest first
SideInOutEntryExitReturn
Long2026-02-182026-07-201.09641.1796+7.37%

Trades happen at the close of the bar that gives the signal, with the whole balance; real fills, slippage and spreads differ. A past result doesn't mean the rule will work again. Not financial advice.

About the Backtesting Calculator

Backtest a simple trading rule on your own price data. Paste daily closing prices or load a CSV export from Yahoo Finance, MetaTrader or Investing.com, pick a moving average crossover, an RSI oversold and overbought rule or a MACD signal-line cross, and see how the rule would have done against simply buying and holding.

The results show the strategy's return and final balance, the number of trades and the win rate, the average trade, the maximum drawdown, the time spent in the market and the fees paid, with a chart of both balances and a list of the trades.

How it works

The rule is checked at the close of every bar. A moving average crossover buys when the fast average closes above the slow one after being at or below it, and sells on the opposite cross. The RSI rule buys when RSI falls below the oversold level and sells when it rises above the overbought level. The MACD rule uses the MACD line crossing its signal line.

Each trade uses the whole balance at that bar's closing price. A trade of value V costs V times the fee rate, so a buy spends the balance divided by one plus the fee and a sale receives the value minus the fee. With shorts turned on, a sell signal also opens a short and a buy signal closes it and goes long.

Buy and hold buys on the first bar with the same fee. A position still open on the last bar is valued at the last close. The calculations are checked against an independent backtester written separately in Python.

Assumptions and limits

  • Orders fill exactly at the close of the signal bar, with no slippage or spread.
  • Fractional quantities are allowed, so the whole balance is always invested.
  • Indicators use the textbook definitions: Wilder's RSI and EMAs started from a simple average.

Worked examples

A crossover on 9 prices

Closes 10, 9, 8, 9, 11, 12, 10, 8, 9 with a 1-bar and 2-bar average and 900 to start: buy at 9, sell at 10 for +11.11%, then buy again at 9, while buy and hold loses 10%.

The same with a 1% fee

The fee on both sides cuts the first trade's profit from 100 to 80.20 and the balance at the end to 970.49.

Going short too

With shorts on, the sell at 10 also opens a short that is closed at 9, ending at 1,100 (+22.22%).

How to use the Backtesting Calculator

  1. Paste the price history. Closing prices or a CSV file, oldest first.
  2. Pick a rule and its settings. Crossover, RSI or MACD, with fees and shorts.
  3. Compare with buy and hold. Return, drawdown, win rate and every trade.

Frequently asked questions

What is backtesting in trading?

Backtesting runs a trading rule over past prices to see what it would have done: when it would have bought and sold, how much it would have made or lost and how deep the falls were. It tests an idea before you risk money on it.

Does a good backtest mean the strategy will work?

No. Markets change, and a rule tuned to fit one stretch of history often fails on the next. Test on several markets and periods, keep the rules simple, and treat a result that looks too good as a warning sign.

Why compare with buy and hold?

Buy and hold is what you would get by doing nothing. A strategy that trades often but returns less than simply holding, or returns the same with bigger drawdowns, isn't adding value once your time and risk are counted.

How are fees and shorts handled?

Every buy and sale is charged the fee rate on its value, so frequent trading costs more. With shorts turned on, the backtest is always in the market after the first signal, flipping between long and short on each signal.

Where can I get price data for a backtest?

Download daily history as a CSV from Yahoo Finance, Investing.com or your broker's platform, such as the MetaTrader history centre, and load the file. The page finds the close column and puts newest-first files into date order.

This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.