Import a Pine script
Paste a TradingView Pine v5 or v6 strategy into the Builder, see which parts were read and which lines were not, and the units it converts.
Paste Pine script turns a TradingView Pine v5 or v6 strategy() script into a flow on the canvas. It uses fixed rules inside your browser. It does not use AI, and nothing is sent anywhere. It is not a Pro feature. It only produces the flow (parts and settings), never source code.
Paste and place
- In the Builder toolbar, open the … menu and choose Paste Pine script.
- Paste the script into the box. The result updates as you type.
- Read the result under the box:
- Can place: N parts from X of Y entries. The script was read.
- These do not fit (N). Each line that could not be read is listed with its line number, the line text and the reason. Nothing is dropped silently.
- Notes. Things that were read but differ slightly (see below).
- Click Place. When some lines do not fit, the button says Place without these, so you choose to place the rest.
Placing replaces the canvas, like opening a template. If nothing in the script can be placed, the button stays disabled and the box shows why.
What is read
//@version=5or//@version=6, and thestrategy(...)declaration.input.int,input.float,input.boolandinput.source. The default value is used.- Assignments with
=and:=, andifblocks. - Indicators:
ta.sma,ta.ema,ta.wma,ta.rma,ta.atr,ta.rsi,ta.cci,ta.wpr,ta.bb,ta.macd,ta.highest,ta.lowestandta.sar, where the Builder has a matching part. - Comparisons,
ta.crossover,ta.crossunder, andand,or,not. strategy.entry,strategy.closeandstrategy.exitwith a stop and a limit in pips.- A stand-alone
hourordayofweekcondition. It becomes a time window or a weekday filter. request.securitywith a constant timeframe string.lookahead_onis not read.- Scripts exported by the Builder’s own Pine export are read back to the parts they came from.
What is rejected
A script that cannot be placed at all stops with one reason:
- no
//@version, a version other than 5 or 6, or nostrategy()call indicator()scriptspyramidingabove 1calc_on_every_tick=trueprocess_orders_on_close=trueuse_bar_magnifier
Inside a script that can be placed, these lines are listed with a reason and are not placed:
- arrays, matrices and maps
- loops (
for,while),switch, andvarstate that persists across bars - user functions that cannot be inlined
- arithmetic between series,
math.max,math.min,math.absand similar,na()tests, and a series that refers to its own past value (x := f(x[1])) ta.*functions without a matching part, the MACD histogram, andta.cross(useta.crossoverorta.crossunder)- limit and stop entry orders (the Builder enters at the market), and trailing exits written as an absolute price (
trail_price) - an hour condition that is not one continuous window, or a weekday condition that includes Saturday or Sunday
If an if block cannot be read, every variable assigned in it is treated as unreadable, so an entry that depends on it is rejected instead of using an old value.
Units
- Pips and ticks.
strategy.exitwithloss,profit,trail_pointsortrail_offsetis in ticks. Ticks are read at 10 ticks per pip, the Builder pip definition for 5- and 3-digit quotes (the same one the Pine and MQL5 export use).loss=500becomes a 50 pip stop, andloss=55becomes 5.5 pips: a whole number of ticks is always exact in decimal pips, and nothing is rounded. Each converted value gets a note saying so. On metals, indices or 2- and 4-digit quotes a pip is not 10 ticks, so check the stop and target after placing. A value that is not a positive whole number of ticks is rejected. Values written asN * pip / syminfo.mintickare read as N pips. - Trailing.
trail_points(the profit at which trailing starts) andtrail_offset(the distance) become a fixed trailing stop with the step set to 0.1 pip. Pine trails on every tick; the Builder checks at the bar close.trail_priceis rejected. - Absolute prices.
stop=andlimit=are read only when written as a distance fromstrategy.position_avg_pricein pips or ATR; any other price expression is rejected. - Lot. A fixed order size in units is converted at 100000 units per lot, only when it is a whole 0.01 lot. Otherwise the lot stays at the Builder default 0.01 and a note says so.
- Bar shift.
close[1]in Pine is read as the Builder shift 2. The Builder export runs once per bar at the bar close, and Pine[j]is Builder shift j + 1. - Time zone.
houranddayofweekuse the exchange time zone of the chart in TradingView. The Builder uses its server time, and a note asks you to check that they match. - MACD signal. TradingView uses an EMA for the signal line. The Builder signal line is an SMA of the MACD line, so values differ slightly. A note says so.
Round trip with the Builder’s own export
The importer was checked against the Builder’s Pine export for all 91 non-portfolio templates (the 9 portfolio templates are not single flows). Parts match for 19 of them; for 14 of those the settings (lot, filters, exits) match as well, and for 5 the settings are not read back from the script. 5 come back changed (3 partial exits are listed as not read, 2 composite parts come back as basic parts). 15 cannot be exported to Pine, and 52 contain constructs from the rejected list above. The same counts are pinned in npm run pine:roundtrip:test.
Next steps
- Read TradingView Pine for the export in the other direction.
- Read Validation messages for the checks a placed flow goes through.