pinescript-to-python-translator
Installation
SKILL.md
🌲 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
-
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