Coming from MQL4 and MQL5

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

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

What you paste · MQL4
#property strict
input int Fast = 20;
input int Slow = 50;
input double Lots = 0.10;
void OnTick()
{
double f = iMA(NULL, 0, Fast, 0, MODE_EMA, PRICE_CLOSE, 0);
double s = iMA(NULL, 0, Slow, 0, MODE_EMA, PRICE_CLOSE, 0);
if (f > s && OrdersTotal() == 0)
OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Ask - 250 * Point, Ask + 500 * Point);
}
What you get back
1strategy "Imported expert advisor"
2market: EURUSD
3bars: 1h
4
5input Fast = 20
6input Slow = 50
7input Lots = 0.1 lots
8
9f = ema(close, Fast)
10s = ema(close, Slow)
11
12when f > s and trades.open().len == 0:
13buy size: Lots, stop: close - 250 * market.point_size, target: close + 500 * market.point_size

Line by line

StatusYour lineWhat happened
Exactinput int Fast = 20 ;an input carried over
Exactinput int Slow = 50 ;an input carried over
Exactinput double Lots = 0.10 ;an input carried over
Adaptedvoid OnTick ( )OnTick became the script body, which runs once per bar; add evaluate: tick to run on every tick
Exactdouble f = iMA ( NULL , 0 , Fast , 0 , MODE_EMAa variable carried over
Exactdouble s = iMA ( NULL , 0 , Slow , 0 , MODE_EMAa variable carried over
Adaptedf > s && OrdersTotal ( ) == 0OrdersTotal() became the number of open trades
Your callSymbol ( )Symbol() has no equivalent yet
AdaptedAskAsk became the close: a backtest here has one price per bar, and live trading uses the right side of the spread
AdaptedAsk - 250 * PointAsk became the close: a backtest here has one price per bar, and live trading uses the right side of the spread
AdaptedAsk + 500 * PointAsk became the close: a backtest here has one price per bar, and live trading uses the right side of the spread
ExactOrderSend ( Symbol ( ) , OP_BUY , Lots , Ask , 3 ,the order carried over with its stop and target
Adaptedif ( f > s && OrdersTotal ( ) == 0 ) OrderSend (a condition that places orders became a rule
Your callthe script headeran expert advisor runs on whatever chart it is attached to, so EURUSD on 1h was filled in: set the ones you want

How the ideas translate

In MQL4 and MQL5In AlgoBarsX
input int Fast = 20;input Fast = 20
input double Lots = 0.10;input Lots = 0.1 lots
iMA(NULL, 0, Fast, 0, MODE_EMA, PRICE_CLOSE, 0)ema(close, Fast)
OrdersTotal() == 0trades.open().len == 0
OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, sl, tp)buy size: Lots, stop: …, target: …
Pointmarket.point_size
PERIOD_H1, PERIOD_D11h, 1d
void OnTick()the body of the script. Add evaluate: tick to the header if it must run inside the bar.
Tip. Stops written as Ask - 250 * Point carry over literally. They read better, and survive gaps better, as distances: stop: 250 points.

Names the importer translates for you

Their nameAlgoBarsX
mode_smasma
mode_emaema
mode_smmasmma
mode_lwmawma
price_closeclose
price_openopen
price_highhigh
price_lowlow
price_medianhl2
price_typicalhlc3
price_weightedohlc4
mathabsabs
mathmaxmax
mathminmin
mathroundround
mathfloorfloor
mathceilceil
mathsqrtsqrt
mathloglog
mathexpexp
mathpowpow
mathsignsign
_symbolmarket.symbol
symbolmarket.symbol
_pointmarket.point_size
pointmarket.point_size
barsbar.index
period_m11m
period_m55m
period_m1515m
period_m3030m
period_h11h
period_h44h
period_d11d
period_w11w
period_mn11M
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