pinescript-to-python-translator

pinescript-to-python-translator is a skill for Claude Code from mphinance/alpha-skills. It costs 29 tokens per session (570 once invoked), scanned A, original, MIT.

A translator that converts TradingView Pine Script strategy files into vectorized Python code. The output is intended for parameter optimization and walk-forward analysis, which tests a strategy across successive historical periods.

In plain words
What is it for?
Use it to convert .pine files, identify signal and risk parameters, extract their allowed ranges, and create Optuna suggestions for testing those parameters in Python.
Why use it?
It helps move a backtest out of TradingView into a Python environment where broader optimization and Monte Carlo testing can be run. It also separates trading, risk, and display settings so chart-only settings are not optimized.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the quant-skills plugin — 60 skills shipped together

Good fit Use it to convert .pine files, identify signal and risk parameters, extract their allowed ranges, and create Optuna suggestions for testing those parameters in Python.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mphinance/alpha-skills/pine-to-python
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mphinance/alpha-skills --skill pine-to-python
Clone the repo
git clone --depth 1 https://github.com/mphinance/alpha-skills

Made for: Claude Code.

Or install quant-skills, the plugin that ships this one along with the rest of its 60 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pinescript-to-python-translator

README.md
[![agentmods](https://agentmods.dev/badge/skills/mphinance/alpha-skills/pine-to-python/github.svg)](https://agentmods.dev/skills/mphinance/alpha-skills/pine-to-python)
Your own site
<a href="https://agentmods.dev/skills/mphinance/alpha-skills/pine-to-python"><img src="https://agentmods.dev/badge/skills/mphinance/alpha-skills/pine-to-python/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pinescript-to-python-translator

Your own site · 80×15
<a href="https://agentmods.dev/skills/mphinance/alpha-skills/pine-to-python"><img src="https://agentmods.dev/badge/skills/mphinance/alpha-skills/pine-to-python.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 570 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00029 $0.00570
Opus 5.5 $0.00012 $0.00228
Sonnet 5.5 $0.00006 $0.00114
Haiku 4.5 $0.00003 $0.00057

Measured 1mo ago against content hash ccc4bae561df, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pinescript-to-python-translator scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/quant-skills/skills/pine-to-python/SKILL.md · 40 lines

How it starts

The opening of the file, as written. The whole thing — 40 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🌲 PineScript to Python Translator

This skill is designed to take raw TradingView PineScript files (.pine) and rigorously deconstruct them into Python-native components so they can be optimized using vectorization and tools like Optuna.

When to use this skill

Use this skill when you want to migrate a backtest from the TradingView ecosystem into a headless Python environment. This is critical for running multi-fold Walk-Forward Analysis (WFA) and Monte Carlo simulations that TradingView cannot handle.

Workflow

  1. Deconstruction & Classification (The IR Build)

    • Parse the .pine script to identify input(), input.int(), input.float(), and input.bool().
    • Classify parameters into three buckets:
      • Signal: Parameters that dictate entries (e.g., length, crossover_threshold).
      • Risk: Parameters that dictate exits (e.g., stop_ticks, trail_offset).
      • Display: Parameters used only for plotting/UI (discard these).
  2. Boundary Extraction

    • For every Signal and Risk parameter, extract the minval, maxval, and step if provided.
    • Format these into Optuna trial suggestions (e.g., trial.suggest_int('length', 10, 50)).
  3. Logic Translation

    • Translate PineScript technical analysis functions (ta.sma, ta.ema, ta.rsi) into their pandas-ta or numpy equivalents.
    • Vectorize the entry and exit conditions. Do not use standard for loops over rows unless path-dependency strictly requires it. Use np.where and .shift() wherever possible.
  4. Hardening & Auditing

    • Repaint Risk: Scan the translation for anything relying on the current unclosed bar data. Force the use of .shift(1) for signal generation.
    • Division by Zero: Wrap all denominators in a np.maximum(denominator, 1e-8) guard to prevent NaN explosions during optimization.

Output Format

The output should be a single Python file containing:

  1. An extract_features(df, params) function that builds all the indicators based on a parameter dictionary.
  2. A generate_signals(df) function that creates a signal column (1 for Long, -1 for Short, 0 for Flat).
  3. A get_optuna_space(trial) function that returns the hyperparameter search space dictionary.

Read the full file on GitHub · 40 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 40 lines · 29 tokens per session scan A ccc4bae561df

Subscribe to this mod's changes

pinescript-to-python-translator is a skill published in the GitHub repository mphinance/alpha-skills (28 stars, last pushed 10d ago), licensed MIT. It adds 29 tokens to every session and 570 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-14.

Related

Other skills, from other repositories

vnpy-export

Export a Vibe-Trading backtest strategy to a runnable vnpy CtaTemplate Python class — supports A-share equities, futures, and crypto via BarGenerator + ArrayManager.

HKUDS/Vibe-Trading · 40 tokens

yfinance

Skill "yfinance" from HKUDS/Vibe-Trading, covering yfinance, deep yahoo interfaces (references/), quick start, ticker format conversion and supported data types.

HKUDS/Vibe-Trading · 41 tokens

tqsdk-trading-and-data

Explain, implement, or debug TqSdk Python workflows for waitupdate or ischanging update loops, market data retrieval, historical download, account type selection, funds or positions or orders or trades, field meanings, order placement or cancellation, target-position tools, TqScenario margin trials, real-account…

shinnytech/tqsdk-python · 286 tokens

miniqmt-to-bigqmt

A conversion guide for moving Python trading strategies from miniQMT, an external trading setup, into the Python environment built into bigQMT, a trading client. It covers code changes, compatibility checks, deployment, and live-trading verification.

litaolemo/xtquant_big_convert · 144 tokens

tushare

A Python interface to Tushare, a financial-data service providing market, company, fund, futures, and other finance-related data. It shows how to authenticate and query the service into pandas tables.

skloxo/TideTrading · 79 tokens

yfinance

Skill "yfinance" from skloxo/TideTrading, covering yfinance, deep yahoo interfaces (references/), quick start, ticker format conversion and supported data types.

skloxo/TideTrading · 46 tokens