← Back to the docs
LootX

Import from Pine Script

Generated: 2026-10-01 docs.lootx.trade
Основы

1Import from Pine Script

How to move an indicator from Pine Script to LootScript: where the import button is, what the converter changes automatically, what it flags for review and how to finish the result.

If an indicator is already written in Pine Script, you don’t have to rewrite it by hand. The terminal converts a .pine file to LootScript: it changes syntax and names, adds missing pieces and writes notes at the top of the file — what was changed and where the converter had to guess.

The converter is a translator, not a compatibility layer. It does not guarantee identical numeric results to the original environment, and it does not add terminal features that don’t exist. After import, open the script, read the notes and verify it on a chart. LootScript was developed independently and is not affiliated with TradingView: the syntax is intentionally similar, but the languages are not compatible.

How to import

Open the Indicators window

Click ƒ on the chart panel — the Indicators window will open.

Click “Import…”

The button sits next to the search field. Choose a .pine, .loot or .txt file. A .loot file is added to the library as-is. A .pine file — a text file resembling Pine Script — is fed through the converter.

Read the result

One of the following lines will appear under the search field:

  • “Imported ‘…’ — no notes; the script is ready.”;
  • “Imported ‘…’: converter notes — N, see the script header”;
  • “Imported ‘…’, but the script does not compile (errors: N)…” — the first error is shown next to the message.

The window will switch to the My scripts section and the search field will be filled with the new script’s name.

Open the script in the Editor

Read the header with notes and fix the items it points out. How — below.

Import does not overwrite a script with the same name: the new file gets a suffix, for example -2. The original file is not changed.

Via the scripts folder

You can also drop name.pine into the scripts folder — on Windows that’s %APPDATA%\TradingTerminal\scripts. On next launch the terminal will create name.loot next to it. If name.loot already exists it is left alone — your edits won’t be lost. To re-convert (for example after a terminal update) delete the .loot.

What the converter does

  • Indentation → braces. if, else if, else, loop and function blocks get braces. Line continuations are merged into one line.
  • Functions. f(x) => becomes func f(x), and the function’s final expression is turned into an explicit return.
  • Loops. Inclusive for i = 0 to 9 becomes half-open for i in 0 .. 10. Direction is taken from the step or from literal bounds; if it’s not visible the converter assumes an ascending loop and notes that.
  • Conditional expressions. if with single-expression branches becomes a ternary operator; switch gets braces.
  • Transparency → alpha. In Pine Script transparency runs 0…100 where 0 is opaque. In LootScript alpha runs 0…255 where 255 is opaque. color.new(c, 50) becomes color.new(c, 128), and a transp= argument is turned into color.new(…) wrapping the color.
  • Names. Old names without a namespace get one: sma → ta.sma. study → indicator, security → request.security, tostring → str.tostring, syminfo.* → sym.*, timeframe.* → tf.*. Short form input(…) receives a typed form: input.int, input.source, etc.
  • Reserved names. A variable whose name is a LootScript keyword or namespace (delta, oi, tf, sym, func …) gets an underscore appended everywhere it appears: delta → delta_.
  • Extra arguments. Arguments that don’t exist for the function in LootScript are removed.
  • Declaration. If the file lacked indicator(…) or strategy(…), the converter will add indicator using the file name.
  • Comments and blank lines remain in place.

The converter never rejects a file. A line it doesn’t understand is not dropped but left as a comment // [не разобрано] … in the same place.

Header with notes

The first header line states the origin — “Imported from a Pine Script (version 5). Converter notes:”. Then one line per change, in source-line order: “Line N: type: what — details”. Notes are written in the interface language.

Note type What it means Check?
renamed Name replaced by LootScript equivalent no
recomputed Transparency converted to alpha no
rewritten Form changed: loop, return, short input type glance
name “…” is reserved in LootScript An underscore was added to the variable no
indicator(…) declaration was missing Declaration added from the file name no
argument removed The function has no such parameter in LootScript yes
assumption The converter guessed: loop direction, input type that couldn’t be inferred yes
not available in this build That function doesn’t exist in the terminal — the script will not compile with an “unknown name” error yes
not parsed The line couldn’t be parsed and was preserved as a comment yes

When you’ve checked them you can remove the header — it’s just comments.

Example

A small Pine Script indicator: bar range columns highlighted when the range is twice the average.

PINE
//@version=5
indicator("Range spike", overlay=false)
len = input.int(20, "Length")
avgRange(n) =>
    r = high - low
    ta.sma(r, n)
base = avgRange(len)
spike = high - low > base * 2
plot(high - low, style=plot.style_columns, color=spike ? color.orange : color.new(color.gray, 60))
plot(base, color=color.blue, trackprice=true)

This is how the converter writes it:

Loot
// Импортировано из скрипта на Pine Script (версия 5). Заметки конвертера:
//
// Строка 6: переписано: avgRange — неявный возврат последнего оператора записан как return
// Строка 9: пересчитано: transp → alpha — прозрачность 0…100 пересчитана в альфу 0…255
// Строка 10: аргумент снят: plot: trackprice — такого параметра в LootScript нет

indicator("Range spike", overlay = false)
len = input.int(20, "Length")
func avgRange(n) {
    r = high - low
    return ta.sma(r, n)
}
base = avgRange(len)
spike = high - low > base * 2
plot(high - low, color = spike ? color.orange : color.new(color.gray, 102), style = plot.style_columns)
plot(base, color = color.blue)

The function gained braces and return, transparency 60 became alpha 102, and trackprice was removed — that parameter doesn’t exist. The “argument removed” note asks you to check whether the parameter was semantically required. Here it only drew a last-value line, and the script works without it.

How to check and refine

  1. Read the header. Start with lines marked “argument removed”, “assumption”, “not available in this build” and “not parsed”.
  2. Check the “Problems” tab in the Editor console. A script with errors will not be added to a chart.
  3. Add to chart and compare with what the original showed across several historical segments.
  4. Ask the assistant. Open the AI assistant and type /fix — it will compile the script, run it over candles and fix errors. You can add a clarification: /fix parse the converter notes in the header. /explain will describe what the script does.

What is not ported

  • Functions that don’t exist in the terminal. The name stays in the code, the note “not available in this build” and a compiler error point to the same place. Replace the call manually or ask the assistant to suggest an alternative.
  • Multiline strings, importing external libraries, exporting functions. The converter transfers what it can write and flags the rest.
  • More than three plot lines. A chart panel draws only the first three plot calls of a script. Put extra series into separate scripts.
  • Live trading. A strategy(…) declaration is converted, but LootScript strategies trade only in the Strategy Tester — on a simulated account.

Next

https://docs.lootx.trade/en/loot/pine-import