# Bring your Pine Script scripts. Keep your work.

> You have spent years on your Pine Script scripts. You should not have to start again. Paste one in, and AlgoBarsX rewrites it and tells you what it did to every line.

Source: https://algobarsx.com/convert/pine-script/

## A real example.

A real run of the importer (8 lines: 5 exact, 2 adapted, 2 your call).

```
//@version=5
strategy("RSI Dip", overlay=true)
len = input.int(14, "RSI Length")
r = ta.rsi(close, len)
if ta.crossover(r, 30)
    strategy.entry("L", strategy.long)
if ta.crossunder(r, 70)
    strategy.close("L")
plot(ta.ema(close, 200), color=color.orange)
```

becomes

```algobarsx
strategy "RSI Dip"
    market: EURUSD
    bars: 1h

input len = 14

r = rsi(close, len)

when crosses_above(r, 30):
    buy size: 1 lot, tag: "L"

when crosses_below(r, 70):
    close_all tag: "L"

plot ema(close, 200), color: orange
```

- Exact: `strategy("RSI Dip", overlay=true)` — strategy() became the script header
- Exact: `len = input.int(14, "RSI Length")` — input() became an input
- Exact: `r = ta.rsi(close, len)` — a calculation was carried over
- Your call: `strategy.entry("L", strategy.long)` — strategy.entry() had no size of its own, so it became one lot: set the size or risk you want
- Adapted: `if ta.crossover(r, 30)` — an if that places orders became a rule
- Exact: `strategy.close("L")` — strategy.close() became close_all
- Adapted: `if ta.crossunder(r, 70)` — an if that places orders became a rule
- Exact: `plot(ta.ema(close, 200), color=color.orange)` — plot() became plot
- Your call: `strategy(...)` — Pine scripts carry no market or bar size, so EURUSD on 1h was filled in: set the ones you want

## How the ideas translate.

| In Pine Script | In AlgoBarsX |
| --- | --- |
| `strategy("RSI Dip", overlay=true)` | strategy "RSI Dip" with market: and bars: stated. Pine takes both from the chart, so they come back as your decision. |
| `len = input.int(14, "RSI Length")` | input len = 14 |
| `ta.rsi(close, len)` | rsi(close, len) |
| `if cond, then strategy.entry(...) under it` | when cond: with buy under it |
| `strategy.close("L")` | close_all tag: "L" |
| `plot(x, color=color.orange)` | plot x, color: orange |
| `var count = 0` | state count = 0 |
| `close[1]` | close[1], exactly the same |

Pine does not say how big the position is, so the import uses one lot and hands the choice back to you. Replace it with `risk: 1%` and a stop.

## How to move a script.

1. **Paste or upload** Open the Terminal, choose Import, and paste your code or pick the file.
2. **Read every note** Each line is marked exact, adapted, or your call. Settle every “your call” before you go on.
3. **Read it back, then test** Check the plain-English description against what your old script did. Then run a test.

## What you gain.

- **It reads itself back** The compiler writes out what the script does in plain English.
- **Units are real** Percent, pips, R and money are types. Mix-ups are caught before anything runs.
- **One script everywhere** The same file draws, tests, alerts and trades.

> **Always read an import before you run it.** No converter is perfect, and some shapes of code import better than others. Other platforms leave things unsaid that AlgoBarsX makes you state, such as the market, the bar size and the trade size. Compare the plain-English description with what your old script did, and test before you deploy.

## Good questions.

**Will every script convert cleanly?** No. Simple, common shapes convert best. An import that does not compile says so, and every changed line carries a note. Always read the result.

**Do I lose my original?** No. Your old script is untouched. Lines that needed a choice keep the original as a comment.

**Is it free?** AlgoBars is $0 a month with no card. Credits pay for AI, tests and auto trades.

## Important

Trading is risky and you can lose money. AlgoBars is software, not a broker or an adviser. Backtests are hypothetical and leave out spread, fees, swaps and slippage. AlgoBarsX is in beta.
