I’ve had my first experience with the MetaTrader 5 indicator coding. It took me two days to rewrite one of my old MT4 indicators to MT5 (actually it was rather a conversion from MQL4 to MQL5). It wasn’t very easy — in fact I’ve expected some sort of backward compatibility, albeit limited, from new MetaTrader platform or some tool from MetaQuotes Software that would do the code conversion automatically. So, I’ve converted BMA (Bands Moving Average) from.mq4 to.mq5 and it retained its full functionality, which is quite great. You can now freely download BMA indicator for MetaTrader 5. If you’ve missed my announcement of MetaTrader 5 Beta Testing you can still download the latest Beta from MetaQuotes.
Now, about the conversion process… From it I can make several early conclusions about the new MQL5 language and its differences from the old MQL4. The conclusions that would be interesting to the MQL developers are the following:
- Conversion isn’t trivial, as many things are done in completely different way now.
- Indicators’ code has became more structured now.
- With the abundance of the new Enumerated types and structures its now easier to write a reliable code, which can is easy to edit.
- The event system is great.
- When coding indicators with MQL5 you can do everything that you could be doing with MQL4.
- The on-line help for MQL5 is still quite raw.
For the traders, it’s hard to come up with something useful from new MT5 indicators because I was only converting an MT4 indicator, not developing something new with a new functionality, but there are advantages I can outline:
- Enumerated types allow more clear input parameter setting — no more numeric codes for MA modes, for example.
- Indicators can now work with the unlimited amount of bars in the chart.
- Indicators can now track and process some values intrinsic to ECN brokers.
Update: By the way, you can share your experience with using the MT5 Beta on our forums: http://www.earnforex.com/forum/f23/your-first-impressions-metatrader-5-beta-2134/
If you want to share your experience in using the MetaTrader 5 beta or coding in MQL5, or if you just have some questions regarding MT5 or MQL5, please use the commentary form below.

October 23rd, 2009 at 3:25 pm
Hello,
What is the difference between your BMA indicator and the standard MA indicator with the MA period of 49? The line is the same.
▼Reply
Andrei Reply:
October 23rd, 2009 at 3:37 pm
It adds two other lines shifted vertically by percentage value – one above the MA line, other – below MA line. You may be not noticing it because of the low timeframe, try D1.
▼Reply
October 23rd, 2009 at 5:02 pm
Thanks Andrei, i see the blue and green line on the H4 timeframe and up.
▼Reply
October 25th, 2009 at 3:36 am
Nice coding. I don’t understand why they have made the default arrays non- time series (ie latest bar is rates_total). It seems more intuitive to write code with latest bar = shift 0. If you look at fai’s excellent MQL4->MQL5 porting table in http://forum.mql4.com/, he suggests converting CLose[] etc using SetAsTimeSeries in OnCalculate.
The other point is that MT5 already has iMA etc coded, but it’s quite tricky to use these with the CopyBuffer command. The MACD example shows one approach.
▼Reply
Andrei Reply:
October 25th, 2009 at 10:05 am
Yeah, this is quite unusual after MQL4 to see the latest bar as rates_total, while the oldest bar is always number 0. That’s why I had to use ArraySetAsSeries(Close, false); to properly convert and correlate close prices of the bars with the bars of the indicator.
▼Reply
January 3rd, 2010 at 9:43 pm
Hello! How Can I convert my favorites mq4 indicators to mq5 indicators?
▼Reply
Andrei Reply:
January 3rd, 2010 at 9:48 pm
Only manually.
▼Reply
January 4th, 2010 at 5:04 pm
I dont know manually convert indicators from mq4 to mq5. Can I send mq4 files somewhere it will be converted?
▼Reply
Andrei Reply:
January 4th, 2010 at 6:18 pm
Maybe there coders that do such conversion for money, but I don’t know any. You may want to wait for the MT5 do be out of beta testing. Perhaps, MetaQuotes will offer some more or less automatic tool for that.
▼Reply
February 24th, 2010 at 12:51 pm
Hi, just read your blog, was hoping you could answer a very very simple question. I know there is a conversion mqh file for the timeseries, but how can you write in the MQL5 proper way the following ?
If High[1]>High[2] ????
Dumb question i know, but although I am experienced in MQL4 I have found no information on how to do the umtost basic stuff in MQL5
Hope you will spare a 1 minute to answer that.
thx
▼Reply
Andrei Reply:
February 24th, 2010 at 10:17 pm
If you want to execute it in the indicator then it’s easy. You have OnCalculate() handler there, it receives High, Low, Close and Open arrays as parameters (just read the helpfile for the exact details). Then in the code you can use High[1] and High[2] the same as in MQL4. Just remember to convert the array to timeseries with ArraySetAsSeries(High, true) if you want the same order of the elements as in MQL4.
▼Reply