SuperAPIAI Directory

pineforge-codegen-mcp

github.com · AI developer platforms

Backtest Pine Script v6 strategies locally by transpiling them to C++ and running them on the deterministic PineForge engine.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

PineForge Backtest MCP is a local, offline MCP server for AI agents, used for deterministic backtesting of Pine Script v6 strategies. Its core purpose is to solve the problem that language models cannot accurately "mentally calculate" backtests: Pine Script's series semantics, intrabar fill order, lookahead rules, and strategy.* order/position logic cannot be reproduced by approximation, and models simulating on their own or hand-writing backtests in Python easily produce hallucinated trades and P&L. This tool instead runs a real deterministic C++ engine and scores it trade-by-trade against TradingView's trade list.

Main capabilities: a container packaged with the pineforge-codegen transpiler, which transpiles Pine Script v6 to C++ and backtests in-process. The toolset covers: backtest_pine (single backtest), backtest_pine_grid (parameter grid sweep), transpile_pine (only performs Pine-to-C++ conversion), fetch_binance_ohlcv (fetches OHLCV from Binance's public API and writes it to CSV), check_tradingview_parity (verifies consistency trade-by-trade against TradingView's own trade list), list_engine_params (lists the parameters accepted by the engine), lookup coverage queries, and mirror-related tools. The Docker image includes 11 tools; the npm package provides the first ten, plus pull_engine_image and check_engine_image, for a total of 12 tools.

Usage: a Docker environment is required; only the Binance fetch tool and check_tradingview_parity when bars are not passed in make external requests (public endpoints). At runtime it communicates via stdio as a self-contained container, mounting the folder containing CSVs to /work. Absolute paths under /work/... should be used in tool parameters (such as ohlcv_csv_path, output_path, report_path), because the working directory inside the container is /app rather than the mount point, and relative paths are lost when the container exits. On Linux it is recommended to add --user "$(id -u):$(id -g)" toensure written files are owned correctly. Startup parameters must include -i and must never include -t, otherwise the TTY will corrupt the stdio JSON-RPC stream. Node ≥ 20 and a running Docker daemon are required; every transpilation and backtest executes docker run --rm --network=none to run the engine image (PINEFORGE_IMAGE, default ghcr.io/pineforge-4pass/pineforge-release:latest). Configurable clients include Claude Desktop (edit claude_desktop_config.json), Cursor (.cursor/mcp.json), Claude Code CLI, and others.

Applicable scenarios: when the user provides a Pine Script v6 strategy and wants to backtest it, evaluate it, determine whether it is profitable, count the number of trades, calculate P&L, or reproduce TradingView results on specified OHLCV, use backtest_pine or the parameter sweep backtest_pine_grid; when only Pine-to-C++ conversion is needed, use transpile_pine; when the user has a TradingView trade list and wants to verify consistency trade-by-trade, use check_tradingview_parity; when the user only gives a trading pair/timeframe and does not provide a data file, use fetch_binance_ohlcv.

Limitations: runs offline; only supports Pine Script v6; requires Docker; PineForge implements only a subset of Pine v6. Backtesting measures a strategy's historical performance, not a prediction of future returns, and does not constitute investment advice; common approximations such as not modeling slippage and commissions, assuming fills at the closing price, and lookahead bias will overestimate profits. This tool is not intended to explain strategy concepts, edit Pine syntax, or provide trading/financial advice.

Scoring data (measurement results recorded in the documentation): release version 1.4.0 (2026-10-07 baseline) records 7,989 scoring probes, 7,983 excellent (99.92%), 6 strong (0.08%), none below strong, 0 engine errors, and an additional 17 probes excluded due to anomalies on the TradingView side. Historical release 1.3.0 (2026-10-06 baseline) records 7,989 probes, 7,982 excellent (99.91%), 7 strong (0.09%). excellent means the same number of trades, at least 99% of TradingView trades matched, entry and exit prices within 0.01%, and per-trade profit and loss within the 1% at the 90th percentile. These are all recorded results for a specific date and sample population, and are not a promise that every script will succeed.

Hosted alternative: provides a Streamable HTTP endpoint, which can be tried without Docker and an API key, but is billed by traffic (100 backtest_pine runs per IP per week, plus edge rate limiting), limited to cryptocurrencies, seven trading venues, and the most recent 365 days of data, with the latest candlestick lagging real time by about one hour; its 11 tools do not include transpile_pine and backtest_pine_grid. The local repository, by contrast, is unlimited, can be offline, can bring your own CSV, and can run grid scans. Regarding engine parameters, list_engine_params provides a local zero-I/O directory, divided into two groups, strategy_overrides (9 strategy(...) header fields) and runtime_args, each item being {key, type, enum?, description}.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools