Docs / Running backtests

Running backtests

Prepare the ticker list, check one set of settings and let PineBag test each ticker in order.

Build the bag

PineBag symbol bag with search, copy, paste and clear controls
The real side panel with ten tickers ready to run.
  1. Search in TradingView.
    Choose Search, find a market and use the PineBag add action. The exchange prefix is preserved.
  2. Paste a list.
    Choose Paste or press ⌘V/Ctrl+V. New lines, commas, semicolons and spaces are accepted; duplicates are ignored.
  3. Copy or reuse it.
    Copy returns one ticker per line. Clear copies the bag before removing it, so Paste can restore it.
  4. Review the tags.
    Use × on a tag to remove one mistake and confirm the count before starting.
Example bagNASDAQ:AAPL NASDAQ:MSFT BINANCE:BTCUSDT CME_MINI:ES1!

Choose where strategy properties come from

Open PineBag Settings and choose TradingView or Script under Strategy properties. The selected source wins when the same value exists in both places; TradingView is the default.

PineBag Settings with TradingView and Script strategy-property priority
TradingView priority uses the chart's current Properties. Script priority uses values declared in strategy().
Default

TradingView priority

Use this when you tune capital, order size, commission and execution assumptions in TradingView. The chart values override matching script values.

Portable

Script priority

Use this when every run must carry the same assumptions inside the .pine file. TradingView only supplies a property that the declaration does not set.

Change parameters in TradingView

TradingView Strategy Properties dialog
Official TradingView Strategy Properties interface. Open the TradingView reference ↗
  1. Add the strategy to the chart.
    Open its settings with the gear icon and choose the Properties tab.
  2. Set account assumptions.
    Check Initial capital, Base currency and Order size.
  3. Set trading costs.
    Enter Commission and Slippage. These apply to every ticker in the bag.
  4. Check leverage and fills.
    Set long/short margin, recalculation and order-fill behavior only when the strategy needs them.
  5. Return to PineBag.
    Keep TradingView priority selected, confirm the summary in the side panel and start the run.
For a fair comparison: do not change the strategy or TradingView Properties while a run is active.

Or keep the parameters in Pine Script

With Script priority, the strategy() declaration becomes the portable source of truth. This template includes the main properties and a small, valid EMA-breakout example.

Open the strategy template with every Properties variable →

↓Download the editable .pine template4 KB · Pine Script v6

Choose the history mode

Fast

Chart history

Uses up to 5,000 loaded bars. It works with any TradingView plan, but ticker start dates can differ.

Aligned

Exact shared range

Tests every ticker between the same dates. It requires a TradingView plan with Deep Backtesting.

What happens during a test

1Validate

PineBag checks the strategy and settings.

2Test

TradingView calculates one ticker after another.

3Combine

PineBag saves the results in one local portfolio report.

Start and monitor the run

  1. Confirm the strategy and bag.
    Check the file, timeframe, capital and ticker count.
  2. Select the history mode.
    Choose fast chart history or an exact shared date range.
  3. Choose Run backtest.
    Keep the TradingView tab open while the progress counter is moving.
  4. Review warnings.
    PineBag names a failed ticker and keeps the completed results.
  5. Open the report.
    The result and tested strategy version are stored locally.

Limits and safe use

Keep the tab open. A large bag takes longer because tickers are tested one after another. Run availability and market data follow your TradingView plan.