Zeal TerminalOpen the chart
Zeal Terminal / Guides

How to backtest a Pine Script strategy and read the results

Updated 26 November 2026

A backtest replays your strategy over the chart's history and records every trade it would have made. Zeal Terminal does this in the browser, with commission and slippage included, and reports the result in the Strategy Tester window. This guide adds a small moving-average strategy and walks through the four tabs of the report.

Try it in Zeal Terminal

Steps

  1. Pine editor. Open the Pine editor.
  2. Code editor. Write or paste a strategy. This one buys when a 10-bar average crosses above a 30-bar average and sells when it crosses back.
  3. Add to chart. Click Add to chart. The strategy runs over every bar and its trades are marked on the chart.
  4. Strategy tester. Open the Strategy Tester window. It holds the report for the strategy on the chart.
  5. Overview tab. Overview shows the equity curve, the account value after each trade, with buy-and-hold for comparison.
  6. Performance Summary tab. Performance Summary has the totals: net profit, profit factor, drawdown and win rate.
  7. List of Trades tab. List of Trades shows every entry and exit with its profit. Read a few to check the strategy trades when you expect it to.
  8. Properties tab. Properties holds the starting capital, commission, slippage and position size the test assumed. Change them in the strategy() call to test other assumptions.

What the numbers mean

  • Net profit is the total of all closed trades after commission and slippage.
  • Profit factor is gross profit divided by gross loss. Above 1 the strategy made money; a result near 1 means it is roughly break-even before real-world costs.
  • Max drawdown is the largest fall from an equity peak to the next low. It is the number to compare with how much loss you could tolerate.
  • Win rate is the share of trades that closed in profit. A low win rate is fine if winners are much larger than losers.
  • Number of trades tells you how much to trust the rest. A handful of trades proves very little.

Common mistakes

  • Trusting a result with few trades. Thirty or more trades is a better starting point; fewer than that is luck as easily as skill.
  • Ignoring costs. A strategy that trades every few bars can look profitable with zero commission and lose money with a realistic one. Set commission and slippage in strategy().
  • Testing on a short window. The tester uses the bars loaded on the chart. Scroll back or choose a higher timeframe to test over a longer period.
  • Over-fitting. A strategy tuned until its backtest looks perfect usually does not repeat. Try the parameters on a different period before believing them.

Frequently asked questions

Does the report include open trades? An open position at the end of the data is shown separately and is marked to the last price.

Why is my report empty? The script must start with strategy(. An indicator() script draws on the chart but places no orders.

Is a backtest a forecast? No. It describes what a rule would have done in the past, not what it will do.

Related guides

  • How to apply a Pine Script to the chart
  • How to find the best Pine Script parameters with the Optimizer

This guide is replayed by an automated test on every release, so the steps here match the app as it is today.

PricingContactRefundsPrivacyTermsCookiesDisclaimer

© 2026 Zeal Terminal. An independent project, not affiliated with TradingView, Inc.