🌲 PineScript to Python Translator
SkillCommerce & financeTranslate TradingView PineScript strategies into vectorized Python strategies suitable for Optuna optimization and walk-forward analysis.
Use 🌲 PineScript to Python Translator in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add 🌲 PineScript to Python Translator and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the 🌲 PineScript to Python Translator skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by mphinance/alpha-skills in skills/pine-to-python/SKILL.md and read by Ahel’s review.
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
-
Deconstruction & Classification (The IR Build)
- Parse the
.pinescript to identifyinput(),input.int(),input.float(), andinput.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).
- Signal: Parameters that dictate entries (e.g.,
- Parse the
-
Boundary Extraction
- For every Signal and Risk parameter, extract the
minval,maxval, andstepif provided. - Format these into Optuna trial suggestions (e.g.,
trial.suggest_int('length', 10, 50)).
- For every Signal and Risk parameter, extract the
-
Logic Translation
- Translate PineScript technical analysis functions (
ta.sma,ta.ema,ta.rsi) into theirpandas-taornumpyequivalents. - Vectorize the entry and exit conditions. Do not use standard
forloops over rows unless path-dependency strictly requires it. Usenp.whereand.shift()wherever possible.
- Translate PineScript technical analysis functions (
-
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.
- Repaint Risk: Scan the translation for anything relying on the current unclosed bar data. Force the use of
Output Format
The output should be a single Python file containing:
- An
extract_features(df, params)function that builds all the indicators based on a parameter dictionary. - A
generate_signals(df)function that creates asignalcolumn (1 for Long, -1 for Short, 0 for Flat). - A
get_optuna_space(trial)function that returns the hyperparameter search space dictionary.
Signals
- GitHub stars
- 27
- Forks
- 5
- Last commit
- Sep 2026
Advanced
- Item type
- skill
- Key
pine-to-python- Source
- github.com/mphinance/alpha-skills
github.com/mphinance/alpha-skills
More in Commerce & finance
Skill · coreyhaines31
More in Commerce & financeagent-payment-x402
Skill · affaan-m
More in Commerce & financecustomer-billing-ops
Skill · affaan-m
More in Commerce & financereview
Skill · thedaviddias
More in Commerce & financestripe-projects
Skill · stripe
More in Commerce & financebacktesting-frameworks
Skill · wshobson
More in Commerce & finance