Saturday, September 25, 2010

Better Linux compatibility with MetaTrader 5

I noticed that installing winetricks and then allfonts and gdiplus packages additional to wine 1.3.5 improves MetaTrader 5 look and feel.

Steps:

1) Install winetricks

http://wiki.winehq.org/winetricks

2) Install allfonts from winetricks

$ winetricks allfonts

3) Install gdiplus from winetricks

$ winetricks gdiplus

Tuesday, September 21, 2010

Improved access to historical quotes Metatrader 5

Those who like you use Metatrader trading platform you have tested dozens sure, maybe hundreds, of making the respective Expert Advisors backtesting the strategy tester. To perform a backtesting over a long period of time will inevitably need the quoted price of the currency pair and for the entire period during which we will test.

In Metatrader 4 is the problem that the number of candles on a chart is limited and therefore limits the price history with which we have to do the backtesting. Metatrader 4 The solution was to manually download the historical prices of candles M1 and then load this data in the Metatrader, although you can download the chart data is better than M1 M1 download and use the script to get a journalist-turned level of acceptable quality modeling for the backtesting is as reliable as possible. Thus we have the problem of gaining access to the information necessary to make our backtesting with good quality directly from the platform, a problem that must be added that not all brokers offer to download files with the historical contributions. Some will be thinking that the History Center of Metatrader 4 is the download function and that what I say is meaningless, so I recommend you read this article about how to make a backtesting in Metatrader 4 before proceeding.

Metatrader 5 on access to historical data M1 is much quicker and easier, indeed in Metatrader 5 only works with graphics data M1, to be handed to the superior temporal, but always using data from 1 minute candles. For example a sail of a 5-minute chart Metatrader 5 is built with data from the five 1-minute candles that compose it. This fact, together with that in Metatrader 5 can establish an unlimited number of candles on a chart (not Metatrader 4) by simply choosing makes monthly charts and back on the chart until the start of it is downloading all historical M1 automatically and that to build this chart are going to download only data M1. And it extends to improving the modeling of backtesting is of the highest quality without the need for additional operations before backtesting.

The History Center of Metatrader 5 or even allows you to view or modify the data as in Metatrader 4, but according MetaQuotes this functionality will be added to the final version of Metatrader 5.

Monday, September 20, 2010

MQL4 and MQL5: Differences at a glance

MQL5 is the new generation language for the new platform MetaQuotes Software Corp. , Metatrader 5 . The developers of the most popular trading platform in Forex are designed to maintain maximum compatibility and mql5 MQL4 but still indicators, expert advisors and scripts written in MQL4 will have to migrate to the new language mql5 or not work due to some important differences between them. In this article I’ll leave some of the most important and general differences to consider when you prepare to upgrade your mql5 programs.

The differences appear at first sight mql5 code are:

In mql5 not have to declare the functions start (), init () and deinit () (function start () was essential for in MQL4).

The number of buffers in the indicators are not limited (in MQL4 the maximum amount of buffers for an indicator was 8).

Mql5 provides automatic conversions between types of variables involved, even in a numeric string.

Local variables are initialized other than string.

Local Arrays are automatically deleted from the cache after use.
Operator precedence as in C + +.
Checking the logical conditions faster and shorter.
Qe speciales replace functions init, start and deinit

In MQL4 contained three features that could be using either a script, an indicator or an Expert Advisor. In mql5 there are many more features and can not all be used interchangeably in any program.

The function init () has an analogous MQL4 mql5 the function OnInit () function start () has its analogue in OnStart () and deinit () in OnDeinit ().

The OnInit and OnDeInit features have the same functions as init and deinit in MQL4, designating them the code that must be executed to initialize or a program written in fading mql5. Therefore these functions passed to mql5 MQL4 can simply rename or call the former functions as follows:

void OnInit () (
init ();
)
OnDeinit void ()
deinit ();
)



You can not do the same for the function start (), since no function mql5 OnStart () that can be used in all types of programs mql5 but there are several functions depending on the type, so for example OnStart () is analogous start () in scripts, OnCalculate () is the main function indicators could and replaced the start () and onTick () it is for the expert advisors. Regarding the above in this paragraph on the role OnStart () I should mention that if a script does not function contine OnStart () code will be compiled as an Expert Advisor. Likewise if an indicator does not contain OnCalculate () as an indicator compilation is impossible.


Predefined Variables MQL5

In MQL5 peredefinidas have Periodic variables such as Bid, Ask and Bars (these must be obtained through those corresponding predefined functions) and others such as Point and Digits have a slightly different expression. MQL5 predefined variables are:
_Digits: Returns the decimal number dei available in the price of contización the symbol of the current graphic.

Point: Pip stores the size of the symbol on the current chart.
LastError: Contains the code of the last error occurred during program execution mql5. Default is the only variable that can be changed through programming mql5 as it can be reset using ResetLastError ().

Period: Stores the current period of a graphic that is running the program.
Symbol: Contains the name of the symbol of the current graphic.
StopFlag: It contains the end point in the execution of a program mql5. When Metatrder five tries to stop a program mql5 _StopFlag changes to true.
UninitReason: Contains the reason code to stop the execution of a program mql5.

Variables exteranas

In MQL4 external variables are declared in the initial part of the program by the name “extern”. In MQL5 this has changed and also external variables are declared at the beginning of the program but with the name “input”.

Timeseries Access

A major change is that there is mql5 timeseries predefined as Open, High, Low, Close, Volume and Time. To access these data is necessary to establish the corresponding functions described in Access to Timeseries and Indicator Data .

Expert Advisors

In MQL4 EA was required Parq even contain the start () function is executed every tick received in Metatrader terminal. In mql5 new events have been made to call the execution of a certain code. This can be used in an EA:

OnTick: analogous to the start of MQL4 function is executed every time you get a new tick.

OnTimer: runs on the basis of a “timer” every so often a time established through EventSetTimer () that will be declared in advance for example in OnInit ().
OnChartEvent: generated by events occurring when the user interacts with the terminal as keystrokes, movements and mouse clicks, movements of objects in the chart with the mouse or creation / deletion of objects. OnChartEvent also run through your call EventChartCustom () function to be processed by OnChartEvent.
OnBookEvent I have not been able to understand that it is this event, I will continue studying for acutalizar this data.

OnTrade: event generated following completion of a transaction between the terminal and the server (eg submission, amendment or cancellation of an order).

OnTester: Event generated when we pass the final test of an EA in eStrategy tester.
You OnCalculate is only for OnStart only indicators and scripts.

Custom Indicators

The main novelty in the MQL5 indicators is that, unlike MQL4, the number of buffers is not limited. This feature will greatly increase the possibilities for developers, but with increasing use of buffers increases memory and the PC needed to run the program.

Another difference to note is the increase of available styles for displaying the indicator on the screen. While MQL4 offered six types, MQL5 offers up to 18. This adds to the great change that has taken on representation of the indicators and graphical objects.

Also changes the direction of indexing of the elements of the buffer indicator. Because the buffer is going to have the conduct of an array type variable, we will go closer in time with increasing the position of the indexed column systems. For example, in the zero position MQL4 return the current value of the indicator while MQL5 zero position is the value of the first calculation, the most ancient data. In MQL5 therefore must specify the type of data to be stored in an array and bind this array to a given buffer and use the access to timeseries described a few paragraphs above.

All these changes make the algorithm for calculating the indicdores in MQL5 recostruído have to be almost entirely if they come from a program written in MQL4.

Conclusion

In my opinion, the language has improved greatly and will greatly increase the chances of the indicators, and scripts Adviors Experts for Metatrader Metatrader 5 on 4 but for users in general without much or any programming knowledge will be very difficult to cope with new language, MQL5 is more sophisticated, more powerful and therefore more complicated.

Saturday, September 18, 2010

Here Comes the New MetaTrader 5 and MQL5

Here is MT5 in action! :

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.

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

Another pleasant introduction is that now we can clear logs.

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

Thursday, September 16, 2010

More Forex Profits With New MT5 Expert Advisors

The long-awaited release of MetaTrader 5 is just around the corner and, believe me, it will be well worth the wait. There is no upgrade path from MetaQuotes’ MetaTrader 4 trading platform to MetaTrader 5. MT5 is a brand new platform and expert advisors, custom indicators, scripts or autotrading robots that run on MT4 will not be compatible with MT5.

MT5 has a new integrated development environment called MQL5 which includes MetaEditor 5, MetaTrader 5 Strategy Tester and MetaQuotes Language 5 (MQL5).

Execution speed is everything when developing autotrading scripts that sometimes need to crunch huge amounts of data in conjunction with real-time price movements. The new MQL5 boasts up to 20 times faster execution speed than the current MQL4 language that is used to develop custom EAs and indicators for MetaTrader 4.

mt5 debug small More Forex Profits With New MT5 Expert Advisors

MetaQuotes has made significant improvements and enhancements in MQL5 over MQL4 that autotrader developers will probably appreciate much more than the average trader but will ultimately benefit the retail trader just as much.  MetaQuotes has made MQL5 an object oriented language which, for programmers, makes the development of EAs quicker, easier and more flexible. The MQL5 programming environment incorporates intellisense which, as most techies would agree, speeds up the development process.  It also has a built-in debugger for testing.

MetaTrader 5 Strategy Tester is the built-in test harness for expert advisors.  It enables a programmer to stress test a newly developed EA on historical data before releasing it to a real trading environment. Strategy Tester features a “beefed-up” reporting facility that not only detects weak points in an EA under development, but also compares its test results to other EAs. This makes for more accurate and efficient code and therefore, better autotraders.  The expert advisors and custom indicators produced by MT5 will be faster, more accurate, and more profitable.

Saturday, September 11, 2010

MQL5

MQL 5 stands for Meta Quotes Language 5 and is an integrated language for programming trading strategies. It is originally developed by Meta Quotes Software Corp. supported by their extensive familiarity and experience in the construction of numerous online trading platforms.
MQL5 is the most up to date programming language that is written in Expert Advisor, numerous scripts and indicators. MQL 5 can be essentially used to create your own expert advisors which will computerize the overall trading administration procedures.
MQL 5 is also flawlessly appropriate for putting into practice your personal trading strategies, which you have devised yourself. Apart from the above benefits, you can also Meta Quotes Language 5 to formulate your own personal custom technical indicators, libraries and scripts.
The object-oriented high-level programming language MQL 5 also engrosses abundant functions which are indispensable for scrutinizing up to date and prior obtained quotes. It also has integrated functions and indicators which proffer enormous assistance in supervising trade positions and calculating them precisely. The MQL 5 language was originally planned to carry out tasks such as writing automated trading stratagems, scrutiny of an assortment of monetary markets, etc.
However, it also facilitates chores such as devising custom technical indicators, writing on a plethora of expert systems; formulate custom, detailed graphical instruments which proffer superb aid in taking vital trading verdicts.
Programs written down in MetaQuotes Language 5 have diverse characteristics and rationales such as: -
   Expert Advisor: – this is an automated trading system bonded up to an assured graphic representation.
 Custom Indicator: – this is a technical indicator written autonomously over and above those previously incorporated hooked on the client terminal.
  Script: – this is a program planned for a solitary implementation of a number of detailed deeds.
   Library: – this is a set of custom functions and can’t begin performing on their own.