# pine-backtester

Adds performance metrics, trade tracking, and statistical validation to Pine Script indicators and strategies. Handy when evaluating trading systems.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 437 installs · ★ 218
- Author: TradersPost
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/TradersPost/pinescript-agents/tree/HEAD/skills/pine-backtester/SKILL.md
- Updated: 2026-07-23
- HTML: https://affpapa.org/en/nevibecode/skills/pine-backtester

## What it does

Evaluating trading scripts requires reliable statistics across historical bars. The skill injects backtesting routines directly into Pine Script strategies and indicators. It calculates win rate, profit factor, maximum drawdown, as well as Sharpe and Sortino ratios. For signal validation, it adds accuracy checks, false positive rates, and Monte Carlo runs.

The implementation focuses on user-defined types (UDTs) to record each executed order. Storing entry prices, exit reasons, and timestamps inside custom types allows plotting trade lines with `xloc.bar_time`, bypassing the standard 5000-bar limit. It applies Pine Script v6 patterns, including multi-section string reports up to 40,960 characters and `for...in` array iteration.

Agent access relies on Read, Edit, Grep, and Glob tools. Traditional loops with dynamic boundaries create infinite loop risks in Pine Script, so the skill enforces safe array iteration or cached boundary sizes.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add TradersPost/pinescript-agents --skill pine-backtester -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/pine-backtester/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/pine-backtester/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add TradersPost/pinescript-agents --skill pine-backtester -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/pine-backtester/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add TradersPost/pinescript-agents --skill pine-backtester -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/pine-backtester/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install TradersPost/pinescript-agents pine-backtester
```

2. **Manually: put the files in place**
- File: `.github/skills/pine-backtester/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add TradersPost/pinescript-agents --skill pine-backtester -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/TradersPost/pinescript-agents --path skills/pine-backtester
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/pine-backtester/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add TradersPost/pinescript-agents --skill pine-backtester -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/TradersPost/pinescript-agents/tree/HEAD/skills/pine-backtester/SKILL.md

## When to use it
- Compute win rate, profit factor, Sharpe, and Sortino ratios
- Measure false positive rates and signal lag across timeframes
- Track historical trade entries and exits using custom UDT structures
- Draw an on-chart summary table for strategy performance
- Run Monte Carlo simulations to assess strategy stability

## Example prompts
- Add maximum drawdown and Sharpe ratio tracking to my Pine Script strategy
- Build an on-chart table showing win rate and profit factor using Pine Script v6
- Refactor trade result calculations to use for...in loops and a custom Trade UDT

## Similar
- [manifoldbt-backtester](https://affpapa.org/en/nevibecode/skills/manifoldbt-backtester.md) — skill · 1700 installs
- [quant-analyst](https://affpapa.org/en/nevibecode/skills/quant-analyst.md) — skill · 944 installs
- [backtesting-frameworks](https://affpapa.org/en/nevibecode/skills/backtesting-frameworks.md) — skill · 16710 installs
- [backtest-expert](https://affpapa.org/en/nevibecode/skills/backtest-expert.md) — skill · 4200 installs
- [llmquant-strategies](https://affpapa.org/en/nevibecode/skills/llmquant-strategies.md) — skill · 512 installs

From the same set: [traderspost/pinescript-agents](https://affpapa.org/en/nevibecode/by/traderspost/pinescript-agents.md) — 5 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
