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.
This feature is available to approved private-beta accounts. Request beta access; you can sign in and use the importer after your request is approved.
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.
Worked example: import, review and backtest
This original long-only example uses EMA crossovers and basic market orders, all in the supported subset:
//@version=6
strategy("EMA crossover example", overlay=true)
fast = ta.ema(close, 12)
slow = ta.ema(close, 26)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
This original AlphaProve tutorial example may be copied, reused and adapted for this exercise. The import dialog asks you to attest “I wrote this script or have the rights to it”; the permission here covers this included example.
- In an approved account, open Library → Import from Pine Script, paste the example as shown or your adaptation, tick I wrote this script or have the rights to it, then choose Translate script. This import costs 2 AI credits.
- In the chat, read the Translation Report before using the Python. For
this example, check that the script is recognized as a strategy and Pine
v6, and that the EMA, crossover/crossunder and entry/close constructs are
listed as mapped. If the parse status is
unparsed, structural verification was unavailable; review the syntax and generated code carefully. A fill-model warning is expected because AlphaProve does not use TradingView's fill rules. The report classifies source constructs; it does not certify that the generated code or results match TradingView. - Read the generated Python and confirm it expresses the same long entry and close rules. If an unexpected construct is approximated or dropped, or the Python does not match your intent, ask for a correction and review it again before running it.
- Choose Run backtest on the Python code block. Select a symbol, timeframe and date window with available market-data coverage; review the capital, leverage, risk and cost settings before submitting. Inspect the resulting trades, equity, fees and drawdown as a simulation, not a forecast.
The example is for learning the import flow, not a trading recommendation or evidence of an edge.
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.
Exporting a saved strategy also sends its saved parameter settings to the translator. Review those settings in the generated Pine script before using it; a translation is not a verification of matching trading results.
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.