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!
No comments:
Post a Comment