Pine Script import & export (beta)
AlphaProve translates TradingView Pine Script strategies into runnable AlphaProve strategies — and translates your AlphaProve strategies back to Pine Script v6. Either direction costs 2 AI credits.
Importing a Pine strategy
Two ways in, both landing in the same chat flow:
- Paste it in chat. The composer detects Pine Script — including partial
pastes that are missing the
//@versionpragma or thestrategy()declaration — and shows an attestation checkbox: confirm you wrote the script (or hold the rights to it) and send. For a partial paste the translator fills the structural gaps with standard assumptions, states each assumption in its reply, and the Translation Report flags the paste as partial. - Library → Import from Pine Script. Paste into the dialog; it opens a chat whose first message is your script.
Before the AI translates anything, a deterministic pre-pass parses your script and classifies every construct. You get a Translation Report with each import: what mapped, what was approximated (with the reason), what was dropped, and honesty warnings about sizing, fills, and repainting. The translated strategy is ordinary AlphaProve Python — backtest, forward-walk, and Monte Carlo all work on it immediately.
Scripts with no strategy.* order calls — indicators, or partial pastes
missing their entries and exits — have no trade rules to translate. The chat
will ask how you'd trade it (or for the rest of the script) instead, and that
turn costs the normal 1 credit. Trade rules are never invented for you.
Rights policy
Paste only scripts you wrote or have the rights to use. The attestation is required on every import, and pasting is the only input — AlphaProve never fetches, scrapes, or extracts scripts from TradingView, and never accesses your TradingView account.
The supported subset
The translator targets the retail Pine v6 subset (v5 scripts usually work; older scripts are translated best-effort without structural verification).
Indicators (ta.*)
| Pine | AlphaProve |
|---|---|
ta.adx / ta.dmi |
ctx.indicators.adx(high, low, close, period=14) |
ta.atr |
ctx.indicators.atr(high, low, close, period=14) |
ta.bb |
ctx.indicators.bollinger_bands(series, period=20, num_std=2.0) |
ta.cci |
ctx.indicators.cci(high, low, close, period=20) |
ta.cmo |
ctx.indicators.cmo(series, period=14) |
ta.crossover / ta.crossunder |
two-bar cross comparison |
ta.ema |
ctx.indicators.ema(series, period) |
ta.highest / ta.lowest |
ctx.indicators.donchian(high, low, period=20) |
ta.hma |
ctx.indicators.hull_ma(series, period) |
ta.kama |
ctx.indicators.kama(series, period=10, fast=2, slow=30) |
ta.kc |
ctx.indicators.keltner(high, low, close, period=20, atr_period=10, mult=2.0) |
ta.linreg |
ctx.indicators.linreg_forecast(series, period=14, ahead=0) |
ta.macd |
ctx.indicators.macd(series, fast=12, slow=26, signal=9) |
ta.mfi |
ctx.indicators.mfi(high, low, close, volume, period=14) |
ta.obv |
ctx.indicators.obv(close, volume) |
ta.pivothigh / ta.pivotlow |
ctx.indicators.williams_fractals(high, low, width) |
ta.roc |
ctx.indicators.roc(series, period=12) |
ta.rsi |
ctx.indicators.rsi(series, period=14) |
ta.sar |
ctx.indicators.parabolic_sar(high, low, af_start=0.02, af_step=0.02, af_max=0.2) |
ta.sma |
ctx.indicators.sma(series, period) |
ta.stoch |
ctx.indicators.stochastic(high, low, close, period=14, smooth_k=3, smooth_d=3) |
ta.supertrend |
ctx.indicators.supertrend(high, low, close, period=10, mult=3.0) |
ta.trix |
ctx.indicators.trix(series, period=15, signal=9) |
ta.tsi |
ctx.indicators.tsi(series, slow=25, fast=13) |
ta.vwap |
ctx.indicators.vwap(high, low, close, volume) |
ta.wma |
ctx.indicators.wma(series, period) |
ta.wpr |
ctx.indicators.williams_r(high, low, close, period=14) |
Orders (strategy.*)
| Pine | AlphaProve |
|---|---|
strategy.entry |
Signal long/short entry |
strategy.exit |
Signal stop-loss / take-profit / trailing-stop fields |
strategy.close |
Signal flat exit |
strategy.close_all |
Signal flat exit |
strategy.order |
market entry (resting orders become market orders) |
strategy.cancel |
omitted — there is no resting-order model |
Inputs and multi-timeframe
input.* calls become tunable strategy parameters (with forward-walkable
sweeps). Same-symbol request.security at a strictly higher timeframe maps to
AlphaProve's confirmed-bar higher-timeframe views — always lookahead-off
semantics. Cross-symbol request.security is not supported yet.
Not translated
These constructs are classified up front and listed as dropped in the Translation Report — never silently improvised:
| Construct | Why |
|---|---|
array. / matrix. / map. |
No equivalent in the retail subset. |
library( / import statements |
Library references cannot be resolved server-side — paste the consuming strategy. |
line. / label. / box. / table. / plot / bgcolor |
Display-only — nothing to trade. |
alertcondition |
Alerts don't exist here; backtests trade the signals directly. |
varip |
Realtime-tick state; our engine is bar-close. |
Exporting to Pine Script
From chat ("convert this to Pine Script") or the strategy page's Export to Pine Script button. The output is a Pine v6 script; AlphaProve features with no Pine equivalent (risk-engine sizing, time-based exits, and similar) are listed as not exported, with reasons.
We parse-verify the emitted script; when we can't, it's delivered anyway with an explicit syntax unverified warning — review it before publishing. Publishing to TradingView is a manual step: paste the script into the Pine editor yourself. AlphaProve never touches your TradingView account.
Why your numbers differ from TradingView
A correct translation still produces different backtest numbers, by design — AlphaProve is one honest engine, not a TradingView clone:
- Fill model. TradingView fills orders against chart OHLC with an intrabar-ordering heuristic; AlphaProve uses its own engine fills (and optional L2 order-book fills). Stop/target ordering can differ on wide bars.
- Costs. TradingView strategies default to zero commission and slippage; AlphaProve applies its cost model. TradingView reports are often optimistic.
- Sizing.
percent_of_equity/cash/ fixed-quantity sizing is replaced by the AlphaProve risk engine (leverage caps, exposure limits, liquidation). Position sizes differ materially. - Pyramiding. Multiple stacked entries (
pyramiding > 1) are not translated — AlphaProve nets one position per symbol. - Repainting. Scripts using
lookahead_onsee future data on TradingView historical bars. AlphaProve forces confirmed-bar semantics, so repainting scripts score worse here — those honest numbers are the point.
Every import's Translation Report states which of these apply to your script.