Coming from thinkScript

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

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

What you paste · thinkScript
input fastLength = 20;
input slowLength = 50;
def fast = ExpAverage(close, fastLength);
def slow = ExpAverage(close, slowLength);
plot FastLine = fast;
plot SlowLine = slow;
AddOrder(OrderType.BUY_TO_OPEN, fast crosses above slow);
AddOrder(OrderType.SELL_TO_CLOSE, fast crosses below slow);
What you get back
1strategy "Imported study"
2market: EURUSD
3bars: 1h
4
5input risk = 1%
6input fastLength = 20
7input slowLength = 50
8
9fast = ema(close, fastLength)
10slow = ema(close, slowLength)
11
12when crosses_above(fast, slow):
13buy risk: risk, stop: atr(14) * 2, target: 2R
14
15when crosses_below(fast, slow):
16close_all side: long
17
18plot fast as FastLine
19plot slow as SlowLine

Line by line

StatusYour lineWhat happened
Exactinput fastLength = 20the input fastLength carried over
Exactinput slowLength = 50the input slowLength carried over
Exactdef fast = ExpAverage(close, fastLength)fast carried over
Exactdef slow = ExpAverage(close, slowLength)slow carried over
Exactplot FastLine = fastthe plot FastLine carried over
Exactplot SlowLine = slowthe plot SlowLine carried over
AdaptedAddOrder(OrderType.BUY_TO_OPEN, fast crosses above slow)thinkorswim sizes an order by the chart settings, so this one risks a set share of the balance with an ATR stop: set the size you want
ExactAddOrder(OrderType.SELL_TO_CLOSE, fast crosses below slow)a closing order carried over

How the ideas translate

In thinkScriptIn AlgoBarsX
input fastLength = 20;input fastLength = 20
def fast = ExpAverage(close, fastLength);fast = ema(close, fastLength)
plot FastLine = fast;plot fast as FastLine
fast crosses above slowcrosses_above(fast, slow)
AddOrder(OrderType.BUY_TO_OPEN, cond)when cond: with buy under it
AddOrder(OrderType.SELL_TO_CLOSE, cond)when cond: with close_all side: long under it
yes, notrue, false
BarNumber()bar.index
Tip. thinkScript orders carry no stop or size, so the import adds a risk input with a stop of two ATRs and a 2R target. Check those three numbers before anything else.

Names the importer translates for you

Their nameAlgoBarsX
yestrue
nofalse
doublenumber
barnumberbar.index
bar_numberbar.index
getsymbolmarket.symbol
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.

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account