Documentation
Pine Script Import Pro
Import a TradingView Pine Script v5 strategy and run it against your own data — with PSO optimization and walk-forward validation that TradingView doesn't offer.
How it works: You paste Pine Script v5 code. partiqon uses AI (Claude) to convert it into a graph — the same visual block graph you'd build by hand. You see every node, can edit it, and can then backtest or optimise it. The conversion is one-shot; the result is a standard graph, not a "Pine runner".
How to use it
- Open the workspace and open or create any strategy.
- Click the Pine Import button in the toolbar (the Pine Script icon).
- Paste your Pine Script v5 strategy code into the text area.
- Give it a name, then click Import.
- partiqon converts the code to a graph and opens it in the editor. Review the blocks — all
input()variables become tunable constants automatically. - Run a backtest or PSO optimisation as usual.
What gets converted
| Pine Script construct | Graph block |
|---|---|
ta.ema(src, len) | Indicator.EMA |
ta.sma(src, len) | Indicator.SMA |
ta.rsi(src, len) | Indicator.RSI |
ta.atr(len) | Indicator.ATR |
ta.macd(...) | Indicator.MACD |
ta.bb(src, len, mult) | Indicator.BollingerBands |
ta.stoch(k, d, ...) | Indicator.Stochastic |
ta.highest(src, len) | Indicator.Highest |
ta.lowest(src, len) | Indicator.Lowest |
ta.crossover(a, b) | Math.CrossesAbove |
ta.crossunder(a, b) | Math.CrossesBelow |
strategy.entry("Long", strategy.long) | Sink.Entry.Long |
strategy.entry("Short", strategy.short) | Sink.Entry.Short |
strategy.close(...) | Sink.Exit |
input.int / input.float / input.bool | Source.Constant (tunable) |
and / or / not | Logic.And / Or / Not |
condition ? a : b | Logic.IfThenElse |
>, <, >=, <=, == | Compare.GT / LT / GTE / LTE / EQ |
+, -, *, / | Math.Add / Sub / Mul / Div |
close / open / high / low | Source.Bar.Field |
Limitations — what doesn't convert
partiqon's graph system covers indicator-based trading logic. Some Pine Script features have no equivalent:
- Pine Script v4 — only v5 is supported. Use TradingView's built-in Pine converter to upgrade v4 scripts first.
request.security()— multi-timeframe data fetching. Use partiqon's Aggregator blocks (M15, M30, H1, D1) instead — they're natively available as graph blocks.- Custom user-defined functions (complex ones) — simple helper functions are usually inlined by the converter; deeply recursive or stateful functions may not map cleanly.
- Arrays and matrices — Pine's array.* and matrix.* API has no block equivalent.
- Drawing functions — plotshape, label.new, line.new etc. are visualization-only; they're ignored during import.
- alert() / alertcondition() — alert triggers are not carried over.
- table.* — dashboard tables are not converted.
- Indicators-only scripts — scripts without
strategy.entry()calls produce no entry nodes. Add entry logic manually after import.
⚠ Always review the imported graph before backtesting. The AI conversion is accurate for well-structured Pine scripts but not guaranteed. Check that all entry/exit conditions connected correctly, especially if your script uses complex nested conditions.
Example: EMA crossover
Here's a simple Pine Script v5 strategy and what it becomes after import:
//@version=5
strategy("EMA Crossover", overlay=true)
fastLen = input.int(9, "Fast EMA")
slowLen = input.int(21, "Slow EMA")
slPips = input.float(20.0, "Stop Loss")
tpPips = input.float(40.0, "Take Profit")
fastEma = ta.ema(close, fastLen)
slowEma = ta.ema(close, slowLen)
if ta.crossover(fastEma, slowEma)
strategy.entry("Long", strategy.long, stop=close - slPips*0.0001, limit=close + tpPips*0.0001)
After import, the graph contains: two EMA blocks (fastLen and slowLen as tunable constants), a CrossesAbove block, a Mul + Sub for stop distance, Mul + Add for take profit, and an Entry LONG sink. All four input.* variables are marked tunable and ready for PSO optimisation.
Tips for best results
- Use
strategy.entry()with explicit stop and take-profit parameters where possible — the converter maps these directly tostop_loss_distanceandtake_profit_distance. - Avoid deeply nested if/else blocks. Flatten conditions with
and/oroperators where possible. - Name your
input()variables clearly — the names become node labels in the graph. - If the conversion produces validation errors, the graph is still saved but flagged. Open it in the editor, find the disconnected nodes (shown in red), and fix the wiring manually.