pinescript-plugin

pinescript-plugin

Provides Pine Script v6 validation and reference lookup for coding agents, enabling them to write correct TradingView indicators with real-time diagnostics and function signatures.

Category
访问服务器

README

<img src="assets/mascot.png" alt="pinescript-plugin mascot: a pine tree inspecting a candlestick chart through a magnifying glass" width="150" align="right" />

pinescript-plugin

Pine Script v6 for coding agents — backed by a real validator, not prose.

Gate Agent Plugins 1.0.0 License


The problem

Ask any coding agent for a TradingView indicator and you get code that looks right, reads fluently, and does not compile.

// Confident. Fluent. Four compile errors.
l = line.new(x1=1, y1=2, x2=3, y2=4, colour=color.red)   // it's `color`, not `colour`
plotshape(cond, shape=shape.triangleup)                   // it's `style=`, not `shape=`
v = math.clamp(x, 0, 1)                                   // math.clamp doesn't exist in Pine
b = box.new(left=1, top=2, right=3, bottom=4, textalign=text.align_left)  // box uses text_halign

Three things make Pine unusually hostile to a language model:

  1. Parameter names are not guessable. label.new takes textalign. box.new takes text_halign. Nothing about either name implies the other.
  2. Several functions have two valid call forms. line.new, label.new and box.new each accept a chart.point or independent coordinates. A model that has only seen one form will insist the other is wrong.
  3. The language keeps moving. TradingView shipped request.footprint(), multiline strings and calc_on_every_history_tick in the last eighteen months — and removed the wrapped-line indentation rules in December 2025. Training data goes stale in both directions.

The result is a loop you have probably lived: the agent writes Pine, you paste it into TradingView, it fails, you paste the error back, it guesses again.

What this does about it

Gives the agent a checker and a reference, so it stops guessing.

MCP tools

Tool What it does
validate_pine_script Runs the real validator, returns structured diagnostics with line numbers
lookup_pine_reference The actual signature of any v6 built-in — parameters, and every overload

Skills

Skill Covers
pinescript-v6 Execution model, overloaded constructors, anti-repainting, platform limits, API through July 2026
pinescript-validation Every diagnostic class and its deterministic fix — plus what the validator cannot see
pinescript-indicator Plotting, drawing objects, tables, alerts. Three CI-validated scaffolds
pinescript-strategy Entries, exits, risk sizing, the five traps that make a backtest lie, webhook payloads

Hook

Every .pine file the agent edits is validated automatically. Not "remember to check your work" — an actual control.

The loop closes inside the conversation instead of across TradingView's compiler.

Two kinds of wrong

Pine breaks in two distinct ways, and most tooling conflates them.

Syntactic — hallucinated functions, wrong parameter names, v4/v5/v6 mixed together. Caused by a thin training corpus and a language that changes quarterly. Costs a minute. Solved here.

Semantic — code that compiles perfectly and is still wrong. A repainting signal. ta.* inside a conditional, silently corrupting its own history. An accumulator missing var, resetting every bar. Costs a funded account:

"one overlooked mistake — like a repainting signal or scope error — can invalidate months of backtesting" — PickMyTrade

Prose cannot fix semantic errors, because the author already believes they are right. Nine semantic checks are specified in SPEC.md and being implemented in the engine — repainting detection, ta.*-in-conditional, accumulator state, lazy-evaluation traps, and the platform limits TradingView enforces but no local tool counts.

Plugin, or VS Code extension?

Both — and the distinction matters, because it is what stops the two disagreeing.

        pinescript-v6-validator  (npm)     ← detection lives here, once
                     │
        ┌────────────┴────────────┐
        ▼                         ▼
  VS Code extension          this plugin
  surface: humans            surface: agents
  squiggles, hover           MCP, skills, hook

A check is written once, in the engine. The extension renders it as a squiggle; this plugin returns it to the model. Neither reimplements it — the moment the same rule exists twice they drift, and a drifted rule means your agent and your editor disagree about the same file.

Skills are plugin-only: prose is useless in an editor and is the whole point for an agent. Editor affordances — formatting, go-to-definition — stay in the extension.

Why this one

It shares an engine with a published VS Code extension. The validator here is the same one running in pinescript-vscode-extension — 1,400+ installs, 4.45★. So the agent and your editor cannot disagree about a file.

That engine carries:

  • 457 function signatures scraped from the official v6 reference, plus a hand-maintained layer for everything TradingView shipped since
  • Explicit overload modelling — a call is valid if it satisfies any form
  • A golden corpus of scripts verified to compile on TradingView, asserted to produce zero errors on every commit

Every Pine example in every skill is extracted and run through that validator in CI. A skill shipping code that fails its own checker would make the whole thing worthless, so the build blocks it.

Install

/plugin marketplace add jpantsjoha/pinescript-plugin
/plugin install pinescript-plugin

The validation engine comes from pinescript-v6-validator on npm — no separate checkout needed.

For Claude Code:

/plugin marketplace add jpantsjoha/pinescript-plugin
/plugin install pinescript-plugin

It also packages for Antigravity/Gemini (gemini-extension.json + GEMINI.md), Codex (.agents/skills/ + AGENTS.md) and Kimi (.kimi-plugin/). All four manifests are checked for consistency by make gate.

To develop against an unreleased engine, point at a built checkout instead:

export PINESCRIPT_VALIDATOR=/path/to/pinescript-vscode-extension

Status: early. Four skills so far. See CHANGELOG.

What's in it

skills/pinescript-v6/          execution model, overloads, anti-repainting, limits
skills/pinescript-validation/  every diagnostic class and its deterministic fix
skills/pinescript-indicator/   validated scaffolds: overlay, oscillator, drawings
skills/pinescript-strategy/    entries, exits, sizing, and the repainting traps
mcp/server.js                  validate_pine_script + lookup_pine_reference
hooks/                         validates every .pine file the agent edits
scripts/                       spec, packaging, skill, link and example validation
tests/                         MCP behaviour tests

make gate runs everything: Agent Plugins 1.0.0 conformance, multi-client packaging consistency, skill frontmatter contracts, reference-URL resolution, embedded Pine validation, and the MCP behaviour tests.

Related projects

Project What it is
pinescript-vscode-extension The VS Code extension — IntelliSense, hover docs, real-time validation. Source of the engine this plugin uses.
googlecloud-plugin Same plugin architecture applied to Google Cloud delivery — solution design, security, SRE, agentic patterns.

Prior art

TradersPost Pine Script plugin covers similar territory and is worth a look. The distinction claimed here is narrow and checkable: a shared validation engine with a published extension, and a CI gate that runs every documented example through it.

Contributing

Found Pine that this validator gets wrong? That is the most valuable bug report available — a false positive is worse than a missed error, because it puts red marks on correct code. Open an issue with the smallest script that reproduces it.

Author

Jaroslav Pantsjoha

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选