Run PineScript backtests offline, on your own data
PineForge transpiles PineScript v6 to native C++ and runs it on your local machine via Docker. Local-first, byte-reproducible, runs anywhere Docker runs. Bring your own OHLCV CSV.
Why offline?
Browser-based backtesting is great for chart-side iteration. Offline backtesting is what you reach for when the next step is shipping money behind the strategy: when you need an audit trail, when CI has to gate every commit, when a result from two months ago has to reproduce bit-for-bit today.
Running backtests offline gives you the things browser-based testers can't: results are byte-reproducible — same input, same output, every time. You pin the engine version, check results into a repository, diff trade lists between commits, and run the entire thing headlessly in your CI pipeline. The CSV you feed in is yours; the binary you run is local; the report you get back is auditable.
The practical list of what offline unlocks: version-pinned engines so a commit from two months ago produces the same trade list today; custom data ingestion so you can test against your exchange's tick reconstructions, your data vendor's point-in-time equity prices, or any alt-data feed you can serialize to OHLCV; CI integration so regressions fail the build before they reach production; and multi-broker portability because your strategy's logic isn't locked to a platform — it's a file.
If you've ever needed to share a backtest result with a colleague and realized the only way to "share" it was to screenshot a chart — offline running is what you're missing.
How it works
Three steps. The full workflow from Pine source to a JSON trade report takes under two minutes the first time and under thirty seconds for every subsequent run.
Step 1 — Get a free codegen API key. Sign up at the early-access form below. The key is emailed to you immediately and has a generous free tier — sufficient for any individual quant's development workflow.
Step 2 — POST your Pine source to the codegen API. The API transpiles PineScript v6 to C++ and returns a compiled shared object. No Pine interpreter is running at runtime — the output is native machine code.
curl -s https://api.pineforge.io/v1/codegen \
-H "Authorization: Bearer $PINEFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"source": "'"$(cat my_strategy.pine | jq -Rs .)"'"}' \
| jq -r '.artifact_url' \
| xargs curl -sL -o strategy.soStep 3 — docker run. Pull the PineForge runtime image and mount your OHLCV CSV alongside the compiled artifact. The engine reads the data file, executes the strategy bar-by-bar, and writes a JSON report to stdout.
docker run --rm \ -v "$(pwd)/strategy.so":/strategy.so \ -v "$(pwd)/ohlcv.csv":/data.csv \ ghcr.io/pineforge/runtime:latest \ run /strategy.so --data /data.csv --output json
The JSON output includes a full trade list with entry and exit prices, bar indices, position sizes, and a summary block with net PnL, max drawdown, total trades, profit factor, and Sharpe ratio. All fields are stable across patch releases of the same major version — safe to parse in scripts.
That's the entire workflow. No GUI, no account re-authentication, no chart loading. If you can run Docker, you can run PineForge offline backtests.
What you can backtest
The short answer: anything you can serialize as OHLCV. PineForge is not connected to any market data provider. You bring the data; the engine runs the strategy.
Crypto from your exchange. Pull raw trade data from Binance, Bybit, Kraken, or any exchange with a REST or WebSocket API. Aggregate to whatever timeframe your strategy uses. Feed the CSV directly. Test on the exact pair-and-venue combination you'll trade.
Equities from your data vendor. Polygon, Norgate, BarChart, Tiingo — pick your source, export point-in-time adjusted prices, run backtests with your actual fills and your actual survivorship-bias-free universe.
Tick reconstructions. If you have Level 2 data and want to test on synthetic 1-second bars reconstructed from ticks, you can. Generate the OHLCV from your tick data and pass it in. The engine doesn't know or care where the bars came from.
Alt-data. Sentiment scores, on-chain metrics, funding rates, options skew — if you can express it as a time series aligned to your bar index, you can incorporate it in Pine via custom data columns and test it offline.
The 162-strategy reference suite in the gallery was backtested against TradingView CSV exports (for parity validation) and custom CSV datasets (for regression testing). 158 of the 162 strategies match the reference trade-for-trade; the remaining four are documented edge cases around trailing stops and OCA groups that we continue to refine.