# Coming from EasyLanguage

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

Source: https://algobarsx.com/docs/from-easylanguage/

This is a real run of the importer on a small EasyLanguage script. The result compiles. 6 lines were read: 3 carried over exactly, 3 were adapted and 1 came back as decisions for you.

```algobarsx
Inputs: FastLen(20), SlowLen(50);
Variables: FastAvg(0), SlowAvg(0);
FastAvg = XAverage(Close, FastLen);
SlowAvg = XAverage(Close, SlowLen);
If FastAvg crosses over SlowAvg then Buy next bar at market;
If FastAvg crosses under SlowAvg then Sell next bar at market;
```

```algobarsx
strategy "Imported EasyLanguage strategy"
    market: EURUSD
    bars: 1h

input FastLen = 20
input SlowLen = 50

state FastAvg = 0
state SlowAvg = 0

FastAvg = ema(close, FastLen)
SlowAvg = ema(close, SlowLen)

when crosses_above(FastAvg, SlowAvg):
    buy size: 1 lot

when crosses_below(FastAvg, SlowAvg):
    close_all side: long
```

## Line by line

| Status | Your line | What happened |
| --- | --- | --- |
| Exact | `FastAvg = XAverage ( Close , FastLen ) ;` | a calculation carried over |
| Exact | `SlowAvg = XAverage ( Close , SlowLen ) ;` | a calculation carried over |
| Exact | `Buy next bar at market ;` | an order at market carried over |
| Adapted | `If FastAvg crosses over SlowAvg then Buy next bar at market ;` | a condition that places orders became a rule |
| Adapted | `Sell next bar at market ;` | sell closed the open position, which became close_all on that side |
| Adapted | `If FastAvg crosses under SlowAvg then Sell next bar at market ;` | a condition that places orders became a rule |
| Your call | `the script header` | EasyLanguage carries no market or bar size, so EURUSD on 1h was filled in: set the ones you want |

## How the ideas translate

| In EasyLanguage | In AlgoBarsX |
| --- | --- |
| `Inputs: FastLen(20);` | input FastLen = 20 |
| `Variables: FastAvg(0);` | state FastAvg = 0 |
| `XAverage(Close, FastLen)` | ema(close, FastLen) |
| `Average, WAverage` | sma, wma |
| `If a crosses over b then …` | when crosses_above(a, b): |
| `Buy next bar at market;` | buy. Market orders already fill at the next bar's open. |
| `Sell next bar at market;` | close_all side: long |
| `CurrentBar` | bar.index |

> **Tip.** EasyLanguage variables become `state` values. Where one is simply recalculated every bar, you can delete the `state` line and keep the assignment.

## Names the importer translates for you

| Their name | AlgoBarsX |
| --- | --- |
| `average` | [`sma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-sma) |
| `xaverage` | [`ema`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-ema) |
| `waverage` | [`wma`](https://algobarsx.com/docs/ref-fn-moving-averages/#ref-wma) |
| `stddev` | [`stdev`](https://algobarsx.com/docs/ref-fn-statistics/#ref-stdev) |
| `standarddev` | [`stdev`](https://algobarsx.com/docs/ref-fn-statistics/#ref-stdev) |
| `truerange` | [`true_range`](https://algobarsx.com/docs/ref-fn-volatility/#ref-true-range) |
| `avgtruerange` | [`atr`](https://algobarsx.com/docs/ref-fn-volatility/#ref-atr) |
| `absvalue` | [`abs`](https://algobarsx.com/docs/ref-fn-math/#ref-abs) |
| `maxlist` | [`max`](https://algobarsx.com/docs/ref-modifiers/#ref-max) |
| `minlist` | [`min`](https://algobarsx.com/docs/ref-fn-math/#ref-min) |
| `squareroot` | [`sqrt`](https://algobarsx.com/docs/ref-fn-math/#ref-sqrt) |
| `expvalue` | [`exp`](https://algobarsx.com/docs/ref-fn-math/#ref-exp) |
| `power` | [`pow`](https://algobarsx.com/docs/ref-fn-math/#ref-pow) |
| `ceiling` | [`ceil`](https://algobarsx.com/docs/ref-fn-math/#ref-ceil) |
| `linearregvalue` | [`linreg`](https://algobarsx.com/docs/ref-fn-trend/#ref-linreg) |
| `c` | [`close`](https://algobarsx.com/docs/ref-var-bars/#ref-close) |
| `o` | [`open`](https://algobarsx.com/docs/ref-var-bars/#ref-open) |
| `h` | [`high`](https://algobarsx.com/docs/ref-var-bars/#ref-high) |
| `l` | [`low`](https://algobarsx.com/docs/ref-var-bars/#ref-low) |
| `v` | [`volume`](https://algobarsx.com/docs/ref-var-bars/#ref-volume) |
| `currentbar` | [`bar.index`](https://algobarsx.com/docs/ref-var-bars/#ref-bar-index) |
| `barnumber` | [`bar.index`](https://algobarsx.com/docs/ref-var-bars/#ref-bar-index) |
| `pi` | `3.14159265` |
| `range` | [`bar.range`](https://algobarsx.com/docs/ref-var-bars/#ref-bar-range) |
| `avgprice` | [`ohlc4`](https://algobarsx.com/docs/ref-var-bars/#ref-ohlc4) |
| `medianprice` | [`hl2`](https://algobarsx.com/docs/ref-var-bars/#ref-hl2) |
| `typicalprice` | [`hlc3`](https://algobarsx.com/docs/ref-var-bars/#ref-hlc3) |

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