This is not Photoshop :) - it's MQL5.
Practically, everything what many developers wanted from MQL 5 and Metatrader 5 was implemented and realized at the highest level. The major change in MQL5 is the introduction of OOP (Object-oriented programming). Professional programmers have now more opportunities, but those who learned to write in MQL4, can use the MQL4 programming in MQL5 without the benefit of OOP. The only difference is functionality, the only thing that must be learned. For example, "Bid" and "Ask" variables no longer exist. To get the "Bid" value, we must use the function:
SymbolInfoDouble(Symbol(),SYMBOL_BID);
The frequently used functions Low [0] or iLow (Symbol (), PERIOD_D1, 0) are also gone, but you can easily recreate them. Historical data functions have now the opportunity to take the historical data from point to point, from one particular bar to another specific bar or on a specified time prior to this. So now you dont have to take the entire visible range of historical data:
MqlRates rates_arrayG[];
Int Bar=30; // read only 30 bars, beginning from 0;
iCopBar=CopyRates(Symbol(),PERIOD_M1,0,Bar,rates_arrayG);
This innovation greatly save memory and time simultaneously.
Some functional improvements that I expected from MQL5:
- Function OnTimer () for processing timer events ( EA can now be dependent of the tick arrival);
- OnTrade () - function for processing trade events - opening and closing of the trading position or volume change;
- OnChartEvent () - event handling of the mouse and keyboard on the chart.
Function OnTimer () is called, if we pre-trigger the timer in a predefined function OnInit (event handler initialization expert). Example:
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
EventSetTimer(1); //every second, we will turn to OnTimer ()
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit()
{
EventKillTimer(); // required to cancel the requetst to the timer
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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 now we can get control not only on the arrival of tick, as before, but also on a timer, that allows you to write full-fledged program operated in real time. This feature allows us to create more featured systems.
The function OnTrade () is called when any of the trade events is happening: placing orders, StopLoss or TakeProfit, changing levels of stoploss or takeprofit, editing or deleting a pending order.
So the monitoring of trading operations events is now much easier than before. There is no need for the checking of the orders on ticks or bars, what previously had to be done in MQL4. So the speed is now much better, particularly in optimization.
The function OnChartEvent () is called at multiple events. I did not test each, but the list of events is impressive:
- CHARTEVENT_KEYDOWN - keyboard is pressed;
- CHARTEVENT_OBJECT_CLICK - mouse click on the graphical object on chart;
- CHARTEVENT_OBJECT_DRAG - move of the graphical object using the mouse;
- CHARTEVENT_OBJECT_ENDEDIT - finishing editing the text CHARTEVENT_CUSTOM + n - ID of the user events;
- CHARTEVENT_CUSTOM_LAST - latest.
- With MQL5 we can control the trading and graphics on a new functional level, as was promised by the developers