| 1 comments | Tweet This Twitter for @MetaTrader5

mql5 website
The website mql5.com is now online! ;) The forum , mql5 documentation and articles section are already working, but the code base is still in development. Great news for all MQL5 developers: a MQL5 book is planned and it will be written by Sergey Kovalyov, author of the MQL4 book.

Now that the MQL5 documentation is online, you don't need a local version of the MQL5 help. The MQL5 language continues developing and the official documentation will be extended and improved, so the online version will contain always the last updates. So if you plan to learn MQL5, the mql5 documentation is the best place to start!

All forum accounts were moved from the MQL4 website, so you can use your existing login, you should only fill your profile and upload an avatar if you use one.

| 1 comments | Tweet This Twitter for @MetaTrader5

Some information about the migration from MQL4 to MQL5:

MQL5 is the development of its predecessor - the MQL4 language, in which numerous indicators, scripts, and Expert Advisors were written. Despite the fact that the new programming language is maximally compatible with the previous-generation language, there are still some differences between these languages. And when transferring programs these differences should be noted.

Information intended to facilitate the adaptation of codes to the new MQL5 language for programmers who know MQL4:

First it should be noted:

• The new language does not contain functions start(), init() and deinit();
• The number of indicator buffers is not limited;
• dll is downloaded immediately after downloading an Expert Advisor (or any other mql5 program);
• Check of logical conditions is shortened;
• When limits of an array are exceeded, the current performance is terminated (critically - with the output of an errors);
• Precedence of operators like in C + +;
• The language offers the implicit type cast (even from string to a number);
• Local variables are not initialized automatically (except for strings);
• Common local arrays are automatically deleted.

Special Functions init, start and deinit
The MQL4 language contained only three predefined functions that could be used in the indicator, script or Expert Advisor (not taking into account the include files *.mqh and library files). In MQL5 there are no such functions, but there are their analogues. The table shows the approximate correspondence of functions.

metatrader 5 - mql5

Functions OnInit and OnDeinit perform the same role as init and deinit in MQL4 - they are designed to locate the code, which must be performed during initialization and deinitialization of mql5 programs. You can either just rename these functions accordingly, or leave them as they are, but add calls of these functions in corresponding places. The start function is replaced by OnStart only in scripts. In Expert Advisors and indicators it should be renamed to OnTick and OnCalculate, respectively.

Example:

void OnInit()
{
//--- Functions is called to initialize
init();
}
void OnDeinit(const int reason)
{
//--- Call the function with deinitialization
deinit();
//---
}
If the indicator or script code does not contain the main function, or the function name differs from the required one, the call of this function is not performed. It means, if the source code of a script doesn't contain OnStart, such a code will be compiled as an Expert Advisor. If an indicator code doesn't contain the OnCalculate function, the compilation of such an indicator is impossible.

Predefined Variables
In MQL5 there are no such predefined variables as Ask, Bid, Bars. Variables Point and Digits have a slightly different spelling.

metatrader 5 - mql5

Access to Timeseries
In MQL5 there are no such predefined timeseries as Open [], High [], Low [], Close [], Volume [] and Time []. The necessary depth of a timeseries can now be set using corresponding functions to access timeseries.

Expert Advisors
Expert Advisors in MQL5 do not require the obligatory presence of the function for handling the events of a new tick receipt - OnTick, as it was in MQL4 (the start function in MQL4 is executed when you receive a new tick), because in MQL5 Expert Advisors can contain pre-defined handler functions are several types of events:

• OnTick – receipt of a new tick;
• OnTimer – timer event;
• OnChartEvent – events of input from the keyboard and mouse, events of a graphic object moving, event of a text editing completion in the entry field of the LabelEdit object;
• OnBookEvent – event of Depth of Market status change.

Custom Indicators

In MQL4, the number of indicator buffers is limited and can't exceed 8. In MQL5 there are no such limitations, but it should be remembered that each indicator buffer requires allocation of a certain part of memory for its location in the terminal, so the new possibility should not be abused.
MQL4 offered only 6 types of custom indicator plotting; while MQL5 now offers 18 drawing styles. The names of drawing types haven't changed, but the ideology of the graphical representation of indicators has changed significantly.
The direction of indexing in indicator buffers also differs. By default, in MQL5 all the indicator buffers have the behavior of common arrays, i.e. 0 indexed element is the oldest one in the history, and as the index increases, we move from the oldest data to the most recent ones.
The only function for working with custom indicators that was preserved from MQL4 is SetIndexBuffer. But its call has changed; now you should specify type of data to be stored in an array, linked to the indicator buffer.
Properties of custom indicators also have changed and expanded. New functions for accessing timeseries have been added, so the total calculation algorithm must be reconsidered.

Graphical Objects
The number of graphical objects in has increased significantly MQL5. But now there is a limitation - functions for working with graphical objects can't be used in custom indicators.
Besides, graphical objects can now be positioned in time with the accuracy of a second in a chart of any timeframe - now object anchor points are not rounded off to the bar opening time in the current price chart.
For objects Arrow, Text and Label now way of binding can be indicated, and for Label, Button, Chart, Bitmap Label and Edit chart corner, to which the object is anchored, can be set.

Source: MQL5 Reference

| 1 comments | Tweet This Twitter for @MetaTrader5

8 new indicators for Metatrader 5:

1. Trading Sessions ( author - vdv2001 )

This is the MQL5 version of the popular indicator that draws a vertical lines seperating the different trading session times. It shows the main 3 trading sessions. There are no input parameters because of the functions TimeTradeServer(), TimeGMT() which gets the time updates automatically. You can customize the colors.

metatrader 5 indicator

Download

2. Color RSI ( author - TheXpert )

RSI - Relative Strength Index Indicator - is a great momentum indicator which compares the average of up and down closes for a specific period of time. You can customize the RSI period and Smooth period and the 4 colors of the lines. The standard RSI value is 14 periods and it can be applied to any time frame. Like with the stochastic indicator, when the RSI is peaking above the 70 level, the market is overbought and when it's exiting the 70 level, downtrend is underway. Read more about trading with RSI here

metatrader 5 indicator

Download

3. Cross MA ( author - TheXpert )

This indicator draws a fast and a slow moving average and fills the space between them with color. Moving averages are one of the most popular and easy to use indicators available for technical analysis and are used to define areas of possible support and resistance and measure the momentum. You can customize the value of Slow/Fast MA and their color.

metatrader 5 indicator

Download

4. Color MACD with MA lines ( author - Ray_dl from Forex-TSD, originally posted here )

A great indicator which consists of Color MACD and 2 MA lines. You can customize all settings.

metatrader 5 indicator

metatrader 5 indicator

Version with 2 colors: Download
Version with 4 colors: Download

5. Price Alert ( author - Andrei, see original post here)

A great tool which can alert you when a certain price level is met. You can get a sound alert ( you can turn it off ) and a e-mail alert! You can use it whenever you wish to be notified of new price levels.

metatrader 5 indicator

Download

6. Histogram Indicator or Fisher indicator for Metatrader 5 ( author - Andrei, see original post here)

This is a version of the the Fisher Transform indicator which was devised John Ehlers.

It calculates the maximum and minimum price levels from the previous periods and detects direction and strength of the trend and based on this signals trend changes. It can be used as the main trend indicator of a trading system, like a signal indicator: If it is above the zero line you have a buy signal and if it's below the zero line you can look for sell signals. In the input parameters you can specify the period in bars on which the maximum and minimum will be calculated. Read more about the Fisher indicator here.

metatrader 5 indicator

Download

7. VarMovAvg ( author - Andrei, see original post here)

This indicator is based on the moving average and can be used for detecting trends. You can customize many options and you can also set a sound alert. periodAMA is the MA period, nfast and nslow are noise filters to filter out spikes, G - smoothing setting. You can also customize the colors.

metatrader 5 indicator

Download

8. Trend Strength - Laguerre ( author - Andrei, see original post here)

This is the Metatrader 5 version of the popular Laguerre indicator. Laguerre reacts rapidly to price changes and can be used as a signal indicator or as an important component of a trading system. It's using only a few data samples so the indicator can be made to be much more responsive to recent price data. More responsiveness translates to faster reaction times in placing the trades and, consequently, improved profitability due to the reduction in signal lag. It works like a RSI indicator, so buy or sell when certain levels are crossed. Read more about Laguerre here.

You can customize the following input parameters: CountBars - amount of bars based on which the indicator performs calculations. The higher the better. Gamma - smoothing value.

metatrader 5 indicator


Download

| 0 comments | Tweet This Twitter for @MetaTrader5

metatrader 5


A new article about custom indicators in Metatrader 5 was posted today on the mql4.com website. It explains the MQL5 indicators, their structure, drawing, types and their programming details, comparing to MQL4. Also, 7 new custom indicators were presented with the article.

Read

| 0 comments | Tweet This Twitter for @MetaTrader5

A script which converts MQL 4 code to MQL 5 code was developed by Keiji and Circlesquares on the MQL4 forum.

First, download the following files and place them in your Metatrader 4 / experts / include folder

- mt4accountinfo.mqh
- mt4string.mqh
- mt4datetime.mqh
- mt4objects_1.mqh
- mt4timeseries_2.mqh

Rewrite MQL 4 to MQL 5 Script

Now, download the latest version of the rewrite script and place it in your Metatrader 4 / experts / scripts folder:

- mq4to5rewrite_sample_v4_2.mq4

After that you will need to place a mql4 indicator, script or ea which you want to convert to MQL 5 in your Metatrader 4 / experts / files folder. Now open Metatrader 4 and run the script. As you can see you must first provide the name (without extension) of your mq4 file and select if it is an indicator (0), EA (2) or script (3) file.

Rewrite MQL 4 to MQL 5 Script

In my case i'm rewritting a MQL4 indicator named ang_DCT:

Rewrite MQL 4 to MQL 5 Script

Now hit the "OK" button and if everything is done, the following message will appear:

Rewrite MQL 4 to MQL 5 Script

After that go to your Metatrader 4 / experts / files folder and you will find the converted mq5 file there:

Rewrite MQL 4 to MQL 5 Script

Now open this file with Metaeditor 5 in compile it:

Rewrite MQL 4 to MQL 5 Script

Try to fix the errors with the MQL4 to MQL5 Porting Table and the last version of the translated MQL5 user guide.

| 0 comments | Tweet This Twitter for @MetaTrader5

FraMa Cross Indicator and EA (author - Paul, see his blog Paul's Forex random walk)

This indicator will show a fast and slow Fractal Moving Average (FRAMA) and places arrows at the open of each bar following an MA cross event. FRAMA is an exponential style moving average and can be a valuable technical indicator because it rapidly follows significant changes in price but becomes very flat in congestion zones so that bad whipsaw trades can be eliminated. The FRAMA is an alternative indicator to the default fractals that is included with the Metatrader 5 installation. Read more about the background of FRAMA here.

FraMa Cross for Metatrader 5

FraMa Cross for Metatrader 5

You can customize the fast and slow MA period. The EA is triggered using the indicator. Because the strategy tester is not available yet, the EA can not be tested for it's effectiveness.

Paul also wrote a useful MQH include file which converts error codes and OrderSend results to strings and a debugging file.

Go to Paul's blog and download