# Coming from Pine Script

> A real import, the ideas side by side, and the names that translate.

Source: https://algobarsx.com/docs/from-pine-script/

This is a real run of the importer on a small Pine Script script. The result compiles. 8 lines were read: 5 carried over exactly, 2 were adapted and 2 came back as decisions for you.

```algobarsx
//@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)
```

```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
```

## Line by line

| Status | Your line | What happened |
| --- | --- | --- |
| 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 |

> **Tip.** 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.

## Names the importer translates for you

| Their name | AlgoBarsX |
| --- | --- |
| `ta.sma` | [`sma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-sma) |
| `ta.ema` | [`ema`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-ema) |
| `ta.rma` | [`rma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-rma) |
| `ta.wma` | [`wma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-wma) |
| `ta.hma` | [`hma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-hma) |
| `ta.vwma` | [`vwma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-vwma) |
| `ta.dema` | [`dema`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-dema) |
| `ta.tema` | [`tema`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-tema) |
| `ta.rsi` | [`rsi`](https://algobarsx.com/docs/ref-fn-momentum/#ref-rsi) |
| `ta.cci` | [`cci`](https://algobarsx.com/docs/ref-fn-momentum/#ref-cci) |
| `ta.roc` | [`roc`](https://algobarsx.com/docs/ref-fn-momentum/#ref-roc) |
| `ta.mom` | [`momentum`](https://algobarsx.com/docs/ref-fn-momentum/#ref-momentum) |
| `ta.stdev` | [`stdev`](https://algobarsx.com/docs/ref-fn-statistics/#ref-stdev) |
| `ta.variance` | [`variance`](https://algobarsx.com/docs/ref-fn-statistics/#ref-variance) |
| `ta.highest` | [`highest`](https://algobarsx.com/docs/ref-fn-structure/#ref-highest) |
| `ta.lowest` | [`lowest`](https://algobarsx.com/docs/ref-fn-structure/#ref-lowest) |
| `ta.median` | [`median`](https://algobarsx.com/docs/ref-fn-statistics/#ref-median) |
| `ta.linreg` | [`linreg`](https://algobarsx.com/docs/ref-fn-trend/#ref-linreg) |
| `ta.correlation` | [`correlation`](https://algobarsx.com/docs/ref-fn-statistics/#ref-correlation) |
| `ta.atr` | [`atr`](https://algobarsx.com/docs/ref-fn-volatility/#ref-atr) |
| `ta.tr` | [`true_range`](https://algobarsx.com/docs/ref-fn-volatility/#ref-true-range) |
| `ta.mfi` | [`mfi`](https://algobarsx.com/docs/ref-fn-momentum/#ref-mfi) |
| `ta.obv` | [`obv`](https://algobarsx.com/docs/ref-fn-volume/#ref-obv) |
| `ta.vwap` | [`vwap`](https://algobarsx.com/docs/ref-fn-volume/#ref-vwap) |
| `ta.barssince` | [`bars_since`](https://algobarsx.com/docs/ref-fn-conditions/#ref-bars-since) |
| `ta.crossover` | [`crosses_above`](https://algobarsx.com/docs/ref-fn-conditions/#ref-crosses-above) |
| `ta.crossunder` | [`crosses_below`](https://algobarsx.com/docs/ref-fn-conditions/#ref-crosses-below) |
| `ta.cross` | [`crosses`](https://algobarsx.com/docs/ref-fn-conditions/#ref-crosses) |
| `ta.cum` | `cum` |
| `ta.trix` | [`trix`](https://algobarsx.com/docs/ref-fn-momentum/#ref-trix) |
| `ta.cmo` | [`cmo`](https://algobarsx.com/docs/ref-fn-momentum/#ref-cmo) |
| `math.abs` | [`abs`](https://algobarsx.com/docs/ref-fn-math/#ref-abs) |
| `math.max` | [`max`](https://algobarsx.com/docs/ref-modifiers/#ref-max) |
| `math.min` | [`min`](https://algobarsx.com/docs/ref-fn-math/#ref-min) |
| `math.round` | [`round`](https://algobarsx.com/docs/ref-fn-math/#ref-round) |
| `math.floor` | [`floor`](https://algobarsx.com/docs/ref-fn-math/#ref-floor) |
| `math.ceil` | [`ceil`](https://algobarsx.com/docs/ref-fn-math/#ref-ceil) |
| `math.sqrt` | [`sqrt`](https://algobarsx.com/docs/ref-fn-math/#ref-sqrt) |
| `math.log` | [`log`](https://algobarsx.com/docs/ref-cmd-logging/#ref-log) |
| `math.exp` | [`exp`](https://algobarsx.com/docs/ref-fn-math/#ref-exp) |
| `math.pow` | [`pow`](https://algobarsx.com/docs/ref-fn-math/#ref-pow) |
| `math.sign` | [`sign`](https://algobarsx.com/docs/ref-fn-math/#ref-sign) |
| `bar_index` | [`bar.index`](https://algobarsx.com/docs/ref-var-bars/#ref-bar-index) |
| `syminfo.tickerid` | [`market.symbol`](https://algobarsx.com/docs/ref-var-market/#ref-market-symbol) |
| `syminfo.ticker` | [`market.symbol`](https://algobarsx.com/docs/ref-var-market/#ref-market-symbol) |
| `syminfo.mintick` | [`market.point_size`](https://algobarsx.com/docs/ref-var-market/#ref-market-point-size) |
| `color.green` | [`green`](https://algobarsx.com/docs/ref-var-colors/#ref-green) |
| `color.red` | [`red`](https://algobarsx.com/docs/ref-var-colors/#ref-red) |
| `color.blue` | [`blue`](https://algobarsx.com/docs/ref-var-colors/#ref-blue) |
| `color.orange` | [`orange`](https://algobarsx.com/docs/ref-var-colors/#ref-orange) |
| `color.yellow` | [`yellow`](https://algobarsx.com/docs/ref-var-colors/#ref-yellow) |
| `color.purple` | [`purple`](https://algobarsx.com/docs/ref-var-colors/#ref-purple) |
| `color.teal` | [`teal`](https://algobarsx.com/docs/ref-var-colors/#ref-teal) |
| `color.gray` | [`gray`](https://algobarsx.com/docs/ref-var-colors/#ref-gray) |
| `color.grey` | [`gray`](https://algobarsx.com/docs/ref-var-colors/#ref-gray) |
| `color.white` | [`white`](https://algobarsx.com/docs/ref-var-colors/#ref-white) |
| `color.black` | [`black`](https://algobarsx.com/docs/ref-var-colors/#ref-black) |
| `color.lime` | [`green`](https://algobarsx.com/docs/ref-var-colors/#ref-green) |
| `color.maroon` | [`red`](https://algobarsx.com/docs/ref-var-colors/#ref-red) |
| `color.silver` | [`gray`](https://algobarsx.com/docs/ref-var-colors/#ref-gray) |
| `color.aqua` | [`teal`](https://algobarsx.com/docs/ref-var-colors/#ref-teal) |
| `strategy.long` | `long` |
| `strategy.short` | `short` |

> **Read every import before you run it.** Compare the plain-English description with what your original did, settle each decision, and backtest before you deploy.
