MQL4 - automated forex trading   /  

Articles

Articles  MetaTrader 5  Here Comes the New MetaTrader 5 and MQL5 To post a new article, please log in or register


Read articles on MQL5
Prepare for the Championship

This article is about
MetaTrader 4
Download MT 4 - 5.5 Mb

Mobile trading!
Buy a license and be mobile in your trading!

Here Comes the New MetaTrader 5 and MQL5 [ ru ]

I'll give just a brief description of some moments.


Fig. 1. It's not Photoshop - it's MQL5.


Almost all that interested me and others in MQL5 and MT5 is implemented on a very high level.

The basic change in MQL5 is the appearance of the object oriented programming. I won't go deep into OOP - it's just that experienced programmers get more possibilities. For those who liked MQL4 and don't know about OOP developers left the possibility to write in MQL5 using the style of MQL4 without OOP. The difference is in the functionality that should be learned again.

Let's take a simple example: the Ask and Bid variables do not exist anymore. In order to get the Bid values the below function should be called:

SymbolInfoDouble(Symbol(),SYMBOL_BID);

There are no frequently used Low[0] or iLow ( Symbol(), PERIOD_D1, 0 ), but you can easily re-construct them. The new functions working with history data give possibilities to read into memory the history data from one point till another one, from a certain bar till another certain bar or from the selected time till the other selected time. Earlier reading of a data series the whole visible range was loaded into memory. Whether you needed it or not, but it was read; and if you needed to read M1, it was read from 1999 (in case there was available history) till the current date, hour and minute.

Now only the necessary range can be read, which considerably saves time and memory.

   MqlRates rates_arrayG[];
   Int Bar=30; // read only 30 bars stating from the zero one
   iCopBar=CopyRates(Symbol(),PERIOD_M1,0,Bar,rates_arrayG);

This feature saves both time and memory.

Such a change in functionality doesn't frighten. We'll simply need time to learn new functions-analogs.

Some functional innovations that I waited from MQL:

  • OnTimer() - function to process the timer events (now you don't need to loop the Expert Advisor to make it work with a certain periodicity independent of the incoming tick);
  • OnTrade() - function to process trade events - trade position opening, closing or volume change;
  • OnChartEvent() - processing events by teh mouse or keyboard.


Let's dwell a little on them.

The OnTimer() function is called if the timer is pre-initialized in the OnInit preset function (processor of EA initialization events).

Example:

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   EventSetTimer(1); //each second we'll refer to OnTimer()
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit()
  {
   EventKillTimer(); // canceling of timer reference must be called at exit
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
   MqlDateTime str1;
   TimeGMT(str1); // new function to get GMT time
   Comment(str1.hour
           ,str1.min
           ,str1.sec
           ,str1.day
           ,str1.mon
           ,str1.year
           ,str1.day_of_year
           ,OrdersTotal()
           ,PositionsTotal()
           );
  }

So, control can be obtained not only at tick receipt as it was earlier, but also from the timer which allows writing real-time manageable programs. With this possibility more elaborate systems can be created.

I liked the OnTrade() function. This function is called at the moment when any of the following trade events triggers: order placing, activation of StopLoss or TakeProfit, change of StopLoss or TakeProfit levels, placing/deletion of a pending order.

Now it's much easier to monitor events connected with trade operations. Now there is no need in loops checking the state of orders at ticks or bars. Such loops are used in MQL4, which considerably reduces the program's performance so important in optimization.

Let's dwell on the OnChartEvent() function. The function call is performed for several events. I didn't manage to test each of them, but the list is impressive:

  • CHARTEVENT_KEYDOWN — key pressing event;
  • CHARTEVENT_OBJECT_CLICK — event of a mouse click on a graphical object belonging to a chart;
  • CHARTEVENT_OBJECT_DRAG — event of a graphical object moving performed by a mouse;
  • CHARTEVENT_OBJECT_ENDEDIT — event of text editing end;
  • CHARTEVENT_CUSTOM+n — identifier of a custom event;
  • CHARTEVENT_CUSTOM_LAST — the last one.

The possibility to manage trading and graphics on a new functional level - this is what the developers have promised.

New graphical objects, buttons, entry field appeared. Chart management has become fantastic, one can even insert pictures from files - this option offers a lot of possibilities for those who like special design. This is not Photoshop, this is the result of MQL5 and MetaTrader 5 possibilities. Among new features is that you can create your own buttons and entry fields adding, for example, a button to close all the open orders, or the button of quick Buy and Sell with preset stop and take parameters.

Fig. 2. Graphical objects allow creating an informational panel.

There is one unpleasant fact: objects cannot be created from indicators. This was made intentionally to quicken the performance of indicators. The good news is that they understand it and, probably, will implement the possibility to start several Expert Advisors in one chart. Thus we'll be able to create EA-indicators with objects and without trading. Such indicators can be created now - they will operate like indicators. Now the task is solved by starting a trading EA in one chart and the EA creating objects in the second one, and then implement the exchange between them.

For example, I managed to transform my breakthrough indicator from MQL4 to MQL5 in several hours. The most time was taken by the function learning and debugging. In MQL5 the code has become shorter.

As for the terminal itself, I was impressed by the number of timeframes. In my opinion there's even the excess. Though, the abundance of minute timeframes can be useful for some traders. Well, now there is only one step to the creation of a freely set timeframe. All data are stored now only as a minute timeframe, so there are no problems with the synchronization of different timeframes - this is an important technological solution.

Now there are no files for different timeframes in the HISTORY catalog



Fig. 3. The whole history is stored in a single file.

Another pleasant introduction is that now we can clear logs.


Fig. 4. Use one button to clear the EA Journal, do delete all unnecessary messages.

This is just a brief review of MetaTrader 5. I can't describe all the system's new features for such a short time period - the testing started on 2009.09.09. This is a symbolical date, and I am sure it will be a lucky number. A few days have passed since I got the beta version of the MetaTrader 5 terminal and MQL5. I haven't managed to try all its features, but I am already impressed.

The magicians from MetaQuotes have created an amazing product. I am a developer with 25 years of experience, have seen the start of many projects and can state this for sure!

Best regards,
Yuriy Zaytsev

Skype: yurazyuraz
yzh@mail.ru


Translated from Russian by MetaQuotes Software Corp.
Original article: http://articles.mql4.com/ru/851

Created: 2009.09.25  Author: Yuriy Zaytsev
Warning: All rights to these materials are reserved by MetaQuotes Software Corp. Copying or reprinting of these materials in whole or in part is prohibited.
Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5

In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.

36 comments: 1 2 3 4   To add comments, please, log in or register

http://pixiefx.web.fc2.com/index.html

http://www.ustream.tv/channel/fx-on-com-perrier

This is a great trading system.

2010.07.20 09:35 mar5555
Will brokers be forced to switch to MT5, or will they be able to support both MT4 and MT5?.

Best Forex Robot


Forex Robot

2010.05.06 04:14 Beakon
its oo? im sold!
2010.02.23 15:23 jcadong5

Mt4 was 5 to 6 years out dated when it came out, Mt5 well its 10 years outdated and its still in bata. This is junk, it is no better then mt4 in that theres is nothing that will aid in trading. only a fool will think that a lot of color to your indicators will make them better. The very few good things here could of easily been added to MT4 with out the complete rewrite. Most of the improvements that I see are already available too mt4 in work around codeing done by others. MQ should take a good look at what is already available in this industry they will see what they are offering here is totally outdated junk. I hope that the brokers will see this and refuse to update the mt4 platform or at lease offer both and let their clients deside which to use.

NEW AND IMPROVED.... what a joke.

2010.01.17 20:20 CockeyedCowboy
Hi to all,

I am a novice in the world of TRADING, and at this moment I am experimenting the beta version of metatrader 5, that in my opinion (although not to perceive very much of programming, MQL), seems to be very good. But I only want to give to a suggestion since MetaTrader 5 is in experimental phase, think that this is possible and that it would go to benefit a little more MetaTrader 5 in the way of visualization of the graphs, a tool as the, PAN Tool and the Area Zoom Tool, I think to be two tools very used by traders, in other softwares and that allow to fast access specify zones of the graph. I leave this suggestion in the hope that the creators of this good software, think and try to incorporate this type of tools, to complement it all the existing others already, in this new MetaTrader 5.


My sincereous regards to all

2009.12.31 20:57 Hydrocon

Hello,


Do you mean I can trash almost 100% of custom indicators and EAs?

Do you remember what happened to MS DOS 4? Why did we use DOS 2, 3 then 5... but NEVER 4?

Do you really want to repeat that experience?


ALX


2009.11.27 16:34 alxalx

This thing is already outdated, good 10 years behind other advanced platforms. I just can not believe programmers don't even consider multimonitor pcs.

This is like repainting a russian made "zaparosec" car to make it more modern. Dan

2009.11.22 19:53 Deno
2009.10.30 13:55 onewithzachy
wwwin wrote:

Can't wait for MT5 to come out, hopefully all the SL TP issues would be corrected

http://fxsignalstb.blogspot.com/


I hope that this MT5 will never come out as a hedging disabled, FIFO foreced and backward incompatible platform. I think that it's trime to start searching alternative platforms. This platform is not suitable for the traders.
2009.10.23 18:44 zenoni

Can't wait for MT5 to come out, hopefully all the SL TP issues would be corrected

http://fxsignalstb.blogspot.com/

2009.10.23 08:29 wwwin
36 comments: 1 2 3 4