Docs menu

TradingView Pine Pro

Paste the Pine Script v6 strategy into the Pine Editor, add it to a chart, read the Strategy Tester, and where its trades differ from MetaTrader 5.

This feature is part of Pro.

TradingView exports a Pine Script v6 strategy (.pine). It can export 107 of 119 parts. The rest are blocked, and the export tells you which ones and why. Getting the source is part of Pro.

Add it to a chart

  1. In the Builder toolbar, choose TradingView (Pine).

    The export buttons in the Builder toolbar with TradingView (Pine) selected
    TradingView (Pine) selected in the Builder toolbar.
  2. Click Download .pine. The file is saved as EA_Builder.pine.

  3. In TradingView, open a chart of the symbol and timeframe named on the Checked under: line at the top of the file. Use a symbol your account has data for.

  4. Open the Pine Editor at the bottom of the chart and clear it.

  5. Paste the whole file. The first line is //@version=6.

  6. Click Add to chart. The strategy is drawn on the chart and the Strategy Tester tab shows its results.

How the script decides

The script runs once per bar, at the bar close. Entries and exits are orders that TradingView fills at the next bar open. Stop loss, take profit, limit and stop orders can still hit inside a bar. The script sets calc_on_every_tick = false and process_orders_on_close = false in the strategy() call to make this so.

The last closed bar is read as [0] in the code, which is “Shift 1” in the Builder. A part that reads the forming bar (Shift 0) is blocked.

Inputs

SettingWhat it doesValues
ContractSizeUnits per 1.0 lot, used to turn a lot size into a quantity.Number, default 100000
LotMin, LotMax, LotStepLimits the lot size the script uses.Numbers, defaults 0.01, 100, 0.01
TZThe server time zone for time filters.IANA name or UTC+n, default Etc/UTC
One input per setting of a partFor example LotSize, SL_Pips_9 or MaxPositions_7. The suffix is the part’s id in the flow.Set in the Builder, editable here

Strategy properties to set

The strategy() call is written with placeholder values for the account. Set them in Strategy Properties (the gear icon on the strategy) or edit the arguments:

  • Initial capital and currency. Placeholders only.
  • Commission. Written as 0.
  • Slippage. Written as 0.

Differences from MetaTrader 5

These are stated in the header of every .pine file under WHAT IS NOT EXPRESSED.

TopicIn Pine
SpreadPine candles carry no spread, so it cannot be applied.
SwapPine strategies have no swap.
Minimum stop distancePine has no broker stop level.
PositionsPine keeps one net position. An opposite entry reverses it, so there are no hedged or two-sided positions.
Trailing stop and break-evenEvaluated at the bar close. MetaTrader 5 does it on every tick.
Indicator start valuesEMA and RMA start values differ slightly from MetaTrader. The values converge.
GapsTradingView applies its own fill model.
Currency conversionTradingView applies its own conversion.

Pine also does not support deciding inside a bar, more than one symbol, reading another timeframe or the measured spread. These parts are listed in Blocks that can’t be exported.

Read the Strategy Tester

Open the Strategy Tester tab under the chart. Overview shows the net profit and drawdown. List of trades shows every trade with its entry and exit. Compare the list with the trades from the Miner.

A few details that the report cannot show:

  • The history you can read depends on your TradingView plan and the data of the exchange behind the symbol. The Miner uses its own price data.
  • A free plan cannot export the trade list as a file.

Results are an approximation of past data. They do not predict future results.

Match status

There is no match mark for Pine. A checked copy of the script has compiled in TradingView, but its trades have not been confirmed to match MetaTrader 5. The header of every file reads Match with the platform tester: not verified. See Match check.

If it will not compile

  • Check that the whole file is pasted, starting with //@version=6.
  • Read the message in the Pine Editor console. The first error is usually the cause.
  • If you changed the file by hand, undo your change and add it to the chart again.

Next steps