- Node.js 18+ (pinets-cli uses modern features like
fetchthat are built into Node 18+)
npm install -g pinets-cliThis makes the pinets command available system-wide.
pinets --version
# 0.1.0You can also run without installing globally. npx downloads the package on first use and caches it:
npx pinets-cli run my_indicator.pine --symbol BTCUSDT --timeframe 60When using npx, replace pinets with npx pinets-cli in all examples in this documentation.
Create a file called rsi.pine:
//@version=5
indicator("RSI", overlay=false)
rsiValue = ta.rsi(close, 14)
plot(rsiValue, "RSI", color=color.purple)
pinets run rsi.pine --symbol BTCUSDT --timeframe 60This will:
- Fetch the last 500 hourly candles for BTCUSDT from Binance
- Run the RSI indicator across all candles
- Print the results as JSON to stdout
The output is a JSON object with two top-level keys:
{
"indicator": {
"title": "RSI",
"overlay": false
},
"plots": {
"RSI": {
"title": "RSI",
"options": { "color": "#7E57C2" },
"data": [
{ "time": 1704067200000, "value": 58.23 },
{ "time": 1704070800000, "value": 61.45 },
...
]
}
}
}indicator: Metadata from theindicator()call (title, overlay, etc.)plots: A map of plot names to their data. Each plot has adataarray of{ time, value }entries.
The indicator is the Pine Script code you want to execute. It can come from:
- A file :
pinets run my_script.pine ... - Piped stdin :
cat my_script.pine | pinets run ...
The file extension doesn't matter (.pine is conventional but not required).
The data source provides the OHLCV candle data that the indicator runs against. You must specify one of:
--symbol: Live data from Binance (e.g.,--symbol BTCUSDT --timeframe 60)--data: A local JSON file with candle data (e.g.,--data ./candles.json)
Two options control how many candles are involved:
| Option | What it does | Default |
|---|---|---|
--candles (-n) |
How many candles appear in the output | 500 |
--warmup (-w) |
Extra candles fetched before the output window | 0 |
Total candles fetched = candles + warmup
The warmup candles are processed by the indicator (so moving averages, RSI, etc. have time to initialize) but are excluded from the output.
pinets run ema200.pine --symbol BTCUSDT --timeframe 1D --candles 100 --warmup 200This fetches 300 daily candles, runs the indicator on all 300, but only outputs the last 100 data points.
By default, results go to stdout. Use --output to write to a file:
pinets run rsi.pine --symbol BTCUSDT -o results.jsonInformational messages (like "Executing...", "Done.") go to stderr, so they don't interfere with JSON output. To suppress them entirely:
pinets run rsi.pine --symbol BTCUSDT -q- Command Reference - Full details on every option
- Data Sources - Learn about JSON data format and live providers
- Output Formats - Understand
defaultvsfullformat - Recipes - Common workflows and integration patterns