Skip to main content
Glama
pineforge-4pass

PineForge-Codegen

backtest_pine

Run a deterministic backtest of a PineScript v6 strategy locally using Docker. Returns parsed JSON report with trades and performance summary.

Instructions

Run a real, deterministic backtest of a PineScript v6 strategy — prefer this over estimating its trades or P&L by reasoning, which is unreliable for Pine (series semantics, intrabar fills, and strategy.* order logic do not reproduce from approximation). Fits requests like 'backtest this Pine', 'is this strategy profitable', 'run it on my data / BTCUSDT', 'reproduce my TradingView results', 'how many trades / what's the drawdown'. Transpile a PineScript v6 strategy and run it against an OHLCV CSV via the pineforge-engine Docker image on the user's local machine. Fully local — transpile + backtest run in-container; nothing leaves the box, no API key. Optional inputs overrides input.() named values from the Pine source (keys = the second arg of input.(...) calls, e.g. 'Fast Length'). Optional overrides overrides strategy(...) header fields (initial_capital, commission_value, default_qty_value, pyramiding, slippage, default_qty_type, commission_type, process_orders_on_close). Returns the parsed JSON report (summary, trades, applied_inputs, applied_overrides, elapsed_seconds). If the report is too large to return inline it is written to report_path and a compact summary (with that path) is returned instead. Use backtest_pine_grid for sweeps.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesPineScript v6 source.
ohlcv_csv_pathYesAbsolute or cwd-relative path to OHLCV CSV with header 'timestamp,open,high,low,close,volume' (timestamp = UNIX ms UTC).
imageNoDocker image override. Defaults to ghcr.io/pineforge-4pass/pineforge-engine:latest.
inputsNoMap of Pine input.*() names → value (string/number/bool). Sent as PINEFORGE_INPUTS env var to the runtime.
overridesNostrategy(...) header overrides. Each key maps to a single argument of the Pine `strategy()` call; only the keys you set are applied. Sent as PINEFORGE_OVERRIDES env var. Call list_engine_params for the full catalog with types and enum values.
runtimeNoEngine runtime args (NOT strategy() header) controlling timeframe semantics and intra-bar fill simulation. input_tf / script_tf set the chart and strategy timeframes — script_tf must be coarser than or equal to input_tf or the engine rejects the run. bar_magnifier + magnifier_samples + magnifier_dist enable sub-bar price-path sampling for tighter stop / limit fills. Each field is optional and only forwarded to the engine when set. Call list_engine_params for the full catalog.
report_pathNoWhere to write the full JSON report IF it is too large to return inline. Large backtests (long trade lists + equity curves) are offloaded to this file and the tool returns a compact summary + report_path instead; read the file for the complete trades/equity. Defaults to pineforge-backtest-<timestamp>.json in the working dir.
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It transparently states that execution is 'fully local — transpile + backtest run in-container; nothing leaves the box, no API key' and explains report offloading behavior when results are too large. While it does not cover every edge case (e.g., error handling), it sufficiently discloses key behavioral traits for a backtesting tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose and usage guidance, followed by structured details on parameters and behavior. While it is fairly long, every sentence serves a purpose: explaining use cases, operational details, and sibling differentiation. It could be slightly more concise, but it remains efficient and well-organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having no output schema, the description clearly explains the return format: a parsed JSON report with summary, trades, applied inputs/overrides, and elapsed seconds. It also covers the offload-to-file mechanism for large reports. Given the tool's complexity with nested objects and multiple parameters, the description provides sufficient detail to understand inputs, operations, and outputs completely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds meaningful context beyond the schema, such as explaining how 'inputs' and 'overrides' are sent as environment variables and describing the runtime object's role in timeframe semantics and intra-bar simulation. This enhances understanding of parameter usage and behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a clear verb+resource pair: 'Run a real, deterministic backtest of a PineScript v6 strategy'. It immediately specifies what the tool does and explicitly distinguishes it from the sibling tool backtest_pine_grid by stating 'Use backtest_pine_grid for sweeps.' This differentiation satisfies the highest level of purpose clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'prefer this over estimating its trades or P&L by reasoning' and lists concrete example requests. It also states when not to use it by referencing the alternative backtest_pine_grid for sweeps. This offers clear context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pineforge-4pass/pineforge-codegen-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server