Traders with existing TradingView strategies can run them unchanged inside Backtest Kit.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-docs/llms.txt
Use this file to discover all available pages before exploring further.
@backtest-kit/pinets executes Pine Script v5/v6 locally via the PineTS runtime, extracts plot() values as structured data, and wires the results directly into backtest-kit’s temporal execution context — so look-ahead bias is impossible and the same .pine file works in both backtest and live modes.
Install
Usage in a Strategy
Load a.pine file with File.fromPath() and call getSignal() to extract a structured ISignalDto:
Code.fromString() — no file needed:
Plot Extraction
getSignal() reads the last bar values from four named plot() calls and maps them to an ISignalDto. Your Pine Script must include these plots for getSignal() to work:
| Plot Name | Value | Description |
|---|---|---|
"Signal" | 1 / -1 / 0 | Long / Short / No signal |
"Close" | close | Entry price |
"StopLoss" | price | Stop loss level |
"TakeProfit" | price | Take profit level |
"EstimatedTime" | minutes | Hold duration (optional, default: 240) |
run() and extract() directly:
extractRows() returns every bar as a typed row with a timestamp field — useful for building datasets or detecting crossovers across history.
60+ Built-In Indicators
Pine Script v5/v6 indicators are available natively — no manual calculation required:Trend
SMA, EMA, DEMA, WMA, Hull MA
Momentum
RSI, MACD, CCI, ROC, Momentum
Volatility
Bollinger Bands, ATR, Keltner Channels
Volume
Volume SMA, OBV, Volume Trend
Oscillators
Stochastic %K/%D, ADX, DI+/DI-
Levels
Support/Resistance, Fibonacci retracements
API Reference
| Function | Description |
|---|---|
getSignal(source, options) | Run Pine Script and return a structured ISignalDto |
run(source, options) | Run Pine Script and return raw plot data |
extract(plots, mapping) | Extract the latest bar values from plots with custom mapping |
extractRows(plots, mapping) | Extract all bars as a timestamped row array |
dumpPlotData(id, plots, name, dir) | Dump plot data to markdown files for debugging |
File.fromPath(path) | Load Pine Script from a .pine file |
Code.fromString(code) | Use inline Pine Script code |
usePine(PineConstructor) | Register a custom Pine constructor |
Plot Export: display=display.data_window
When using the @backtest-kit/cli --pine mode, only plot() calls that include display=display.data_window are exported as output columns. Plots using the default display=display.all are rendered on the TradingView chart overlay but are not accessible as named keys in the output. Name each output plot explicitly:
run() directly to ensure all expected plot names are available in the extracted output.
Memoized Execution
File reads are memoized across strategy ticks. The same.pine file loaded repeatedly during a backtest is parsed only once — subsequent calls return the cached result. This makes Pine Script indicators fast enough for high-frequency backtests without any explicit caching in strategy code.
Visual Pine Script Editor
The@backtest-kit/cli --editor flag opens a browser-based editor that lets you write, run, and iterate on Pine Script indicators against live exchange data. The chart updates each time you click ▶ Run.
The
limit parameter must cover the warmup bars required by your indicators. For example, an EMA(50) needs at least 50 bars to produce a valid value. Bars before warmup completes show N/A in the output. Set limit generously — 100–200 is a safe default for most indicators.