← 返回
数据分析 中文

PineTS - PineScript executor

Run Pine Script indicators from the command line using pinets-cli. Use when asked to execute, test, or analyze Pine Script indicators, calculate technical an...
使用 pinets-cli 从命令行运行 Pine Script 指标。当请求执行、测试、分析指标或计算技术分析时使用。
alaa-eddine
数据分析 clawhub v1.0.0 1 版本 99916.2 Key: 无需
★ 4
Stars
📥 1,113
下载
💾 16
安装
1
版本
#latest

概述

pinets-cli — Run Pine Script Indicators from the Terminal

pinets is a CLI tool that executes TradingView Pine Script indicators via the PineTS runtime. It outputs structured JSON with calculated indicator values.

Installation

# Global install
npm install -g pinets-cli

# Or run directly with npx (no install needed)
npx pinets-cli run indicator.pine --symbol BTCUSDT -q

Verify (if installed globally):

pinets --version

When using npx, replace pinets with npx pinets-cli in all examples below.

Core command

pinets run [file] [options]

The indicator can be a file argument or piped from stdin.

Options

Data source (one required)

| Flag | Description |

| ----------------------- | -------------------------------------------------------------------------------------------- |

| -s, --symbol | Symbol from Binance (e.g., BTCUSDT, ETHUSDT, SOLUSDT.P for futures) |

| -t, --timeframe | Candle timeframe: 1, 5, 15, 30, 60, 120, 240, 1D, 1W, 1M (default: 60) |

| -d, --data | JSON file with candle data (alternative to --symbol) |

Output

| Flag | Description |

| --------------------- | -------------------------------------------------------------- |

| -o, --output | Write to file instead of stdout |

| -f, --format | default (plots only) or full (plots + result + marketData) |

| --pretty | Pretty-print JSON |

| --clean | Filter out null, false, and empty values from plot data |

| --plots | Comma-separated list of plot names to include (default: all) |

| -q, --quiet | Suppress info messages (essential when parsing stdout) |

Candle control

| Flag | Description |

| ------------------- | -------------------------------------------------------- |

| -n, --candles | Number of output candles (default: 500) |

| -w, --warmup | Extra warmup candles excluded from output (default: 0) |

Debug

| Flag | Description |

| --------- | ------------------------------------------- |

| --debug | Show transpiled JavaScript code (to stderr) |

Usage patterns

Run a .pine file with live Binance data

pinets run indicator.pine --symbol BTCUSDT --timeframe 60 --candles 100 -q

Run with warmup (important for long-period indicators)

# EMA 200 needs at least 200 bars to initialize
pinets run ema200.pine -s BTCUSDT -t 1D -n 100 -w 200 -q

Pipe Pine Script from stdin

echo '//@version=5
indicator("RSI")
plot(ta.rsi(close, 14), "RSI")' | pinets run -s BTCUSDT -t 60 -n 20 -q

Run with custom JSON data

pinets run indicator.pine --data candles.json --candles 50 -q

Save output to file

pinets run rsi.pine -s BTCUSDT -t 60 -o results.json -q

Get full execution context

pinets run indicator.pine -s BTCUSDT -f full -q --pretty

Filter signals with --clean (for signal-based indicators)

# Without --clean: 500 entries, mostly false
pinets run ma_cross.pine -s BTCUSDT -t 1D -n 500 -q

# With --clean: Only actual signals
pinets run ma_cross.pine -s BTCUSDT -t 1D -n 500 --clean -q

Select specific plots with --plots

# Get only RSI, ignore bands
pinets run rsi_bands.pine -s BTCUSDT --plots "RSI" -q

# Get only Buy and Sell signals
pinets run signals.pine -s BTCUSDT --plots "Buy,Sell" -q

# Combine both: only signals, only true values
pinets run signals.pine -s BTCUSDT --plots "Buy,Sell" --clean -q

Output structure

default format

{
  "indicator": {
    "title": "RSI",
    "overlay": false
  },
  "plots": {
    "RSI": {
      "title": "RSI",
      "options": { "color": "#7E57C2" },
      "data": [
        { "time": 1704067200000, "value": 58.23 },
        { "time": 1704070800000, "value": 61.45 }
      ]
    }
  }
}

full format

Adds result (raw return values per bar) and marketData (OHLCV candles) to the default output.

JSON data format (for --data)

[
  {
    "openTime": 1704067200000,
    "open": 42000.5,
    "high": 42500.0,
    "low": 41800.0,
    "close": 42300.0,
    "volume": 1234.56,
    "closeTime": 1704070799999
  }
]

Required fields: open, high, low, close, volume. Recommended: openTime, closeTime.

Pine Script quick reference

pinets-cli accepts standard TradingView Pine Script v5+:

//@version=5
indicator("My Indicator", overlay=false)

// Technical analysis functions
rsi = ta.rsi(close, 14)
[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)
sma = ta.sma(close, 20)
ema = ta.ema(close, 9)
bb_upper = ta.sma(close, 20) + 2 * ta.stdev(close, 20)

// Output — each plot() creates a named entry in the JSON output
plot(rsi, "RSI", color=color.purple)

Important notes

  • Always use -q when parsing JSON output programmatically.
  • Warmup matters: Indicators with long lookback periods (SMA 200, EMA 200) produce NaN for the first N bars. Use --warmup to pre-feed the indicator.
  • time values are Unix timestamps in milliseconds.
  • Errors go to stderr with exit code 1.
  • The tool bundles PineTS internally — no additional npm packages are needed at runtime.

Warmup recommendations

| Indicator | Minimum warmup |

| ------------------- | -------------- |

| SMA(N) / EMA(N) | N |

| RSI(14) | 30 |

| MACD(12,26,9) | 50 |

| Bollinger Bands(20) | 30 |

| SMA(200) | 200+ |

Rule of thumb: set warmup to 1.5x-2x the longest lookback period.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 06:13 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 166 📥 60,259
data-analysis

Stock Analysis

udiedrichsen
{"answer":"基于雅虎财经数据,分析股票与加密货币。支持投资组合管理、自选股预警、股息分析、8维评分、热门趋势扫描及传闻/早期信号探测。适用于股票分析、持仓追踪、财报异动、加密监控、热门股追踪或提前发掘非主流传闻。"}
★ 270 📥 57,034
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,874