tag:blogger.com,1999:blog-85627729032592197842024-03-13T13:45:27.196-07:00Best Servis MQL5mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-8562772903259219784.post-21758978332298995202010-11-04T09:15:00.000-07:002010-11-16T10:24:45.074-08:00Converting MQL 4 to MQL 5<div style="text-align: center;">7 Steps</div>1) First, download the following files and place them in your Metatrader 4 / experts / include folder<br />
<a href="http://www.fx1618.com/mt5/files/mt4accountinfo.mqh">- mt4accountinfo.mqh</a><br />
<a href="http://www.fx1618.com/mt5/files/mt4string.mqh">- mt4string.mqh</a><br />
<a href="http://www.fx1618.com/mt5/files/mt4datetime.mqh">- mt4datetime.mqh</a><br />
<a href="http://www.fx1618.com/mt5/files/mt4objects_1.mqh">- mt4objects_1.mqh</a><br />
<a href="http://www.fx1618.com/mt5/files/mt4timeseries_2.mqh">- mt4timeseries_2.mqh</a><br />
<div style="text-align: left;"><center><img src="http://www.fx1618.com/mt5/images/convert_mql5_2[1][1].png" title="" border="0"></center><br />
</div><div style="text-align: left;">2) Now, download the latest version of the rewrite script and place it in your Metatrader 4 / experts / scripts folder:</div><div style="text-align: left;"><a href="http://www.fx1618.com/mt5/files/mq4to5rewrite_sample_v4_2.mq4">- mq4to5rewrite_sample_v4_2.mq4</a></div><div style="text-align: left;"><br />
</div><div style="text-align: left;"><br />
3) 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. </div><div style="text-align: left;">4) 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.</div><div style="text-align: center;"><br />
</div><div style="text-align: center;">clickable!</div><div style="text-align: left;"><center><img src="http://www.fx1618.com/mt5/images/thumb3215968.png" title="" border="0"></center><br />
</div><div style="text-align: center;">In my case i'm rewritting a MQL4 indicator named ang_DCT:</div><div style="text-align: center;"><center><img src="http://www.fx1618.com/mt5/images/convert_mql5_3[2][1].png" title="" border="0"></center></div><div style="text-align: left;">5) Now hit the "OK" button and if everything is done, the following message will appear:</div><div style="text-align: left;"><center><img src="http://www.fx1618.com/mt5/images/convert_mql5_4[2].PNG" title="" border="0"></center><br />
</div><div style="text-align: left;">6) After that go to your Metatrader 4 / experts / files folder and you will find the converted mq5 file there:</div><div style="text-align: left;"><center><img src="http://www.fx1618.com/mt5/images/convert_mql5_5[1][1].png" title="" border="0"></center><br />
</div><div style="text-align: left;">7) Now open this file with Metaeditor 5 in compile it:</div><div style="text-align: left;"><br />
</div><div style="text-align: center;">clickable!</div><br />
<center><img border="0" src="http://www.fx1618.com/mt5/images/thumb3216015.png" title="" /></center><br />
<br />
<div></div>mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-38256508289944189872010-10-20T09:14:00.000-07:002010-11-16T09:15:28.440-08:00Metatrader 5<b>Metatrader 5 </B>div><br />
<div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif">· receiving quotes and news in real-time mode; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· viewing price charts of financial securities in one of 21 timeframes ; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· performing trade operations; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· viewing depth of market and trading stock symbols; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· controlling and managing open positions and pending orders; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· conducting technical analysis using 38 built-in indicators and 39 graphical objects; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· writing Expert Advisors, custom indicators, scripts and functions in MetaQuotes Language 5 (MQL 5); </font></div><div><font class="ws9" face="MS Reference Sans Serif">· working with different language interfaces. </font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif">For making a decision to trade, reliable on-line information is necessary. For that, quotes and news are delivered at the terminal in the real-time mode. On basis of on-line delivered quotes, it is possible to analyze markets using technical indicators and line studies. Expert Advisors allow to work off routine of observing markets and controlling of own positions. Moreover, to ensure more flexible control over positions, several order types are built into the terminal.</font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font face="MS Reference Sans Serif"><b><a href="http://www.fx1618.com/mt5/files/MetaTrader 5.zip" target="_blank" class="link1">Download METATRADER 5 (MT5) >>>></a></B></font></div><div><font face="MS Reference Sans Serif"><b><br />
</B></font></div><div align=center><font face="MS Reference Sans Serif"><b><a href="http://www.fx1618.com/mt5/files/Metaeditor5_User-Guide.rar" class="link1">Download Metatrader 5 Terminal User Guide >>></a></B></font></div><div align=center><font class="ws12" face="MS Reference Sans Serif"><b><br />
</B></font></div><div align=center><font class="ws12" face="MS Reference Sans Serif"><b>----------------------------</B></font></div><div align=center><font class="ws12" face="MS Reference Sans Serif"><b><br />
</B></font></div><div align=center><font class="ws16" color="#DF4800" face="MS Reference Sans Serif">Articles about Metatrader 5</font></div><div align=center><font class="ws12" color="#DF4800" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font class="ws9" face="MS Reference Sans Serif"><a href="http://www.fx1618.com/mt5/mql4-to-mql5.html" target="_blank" class="link1">Converting MQL 4 to MQL 5</a></font></div><div align=center><font class="ws9" face="MS Reference Sans Serif"><a href="http://www.fx1618.com/mt5/mt5-crscript.html" target="_blank" class="link1">Creation a script for MT 5 - Instantly delete all objects</a></font></div><div align=center><font class="ws9" face="MS Reference Sans Serif"><a href="http://www.fx1618.com/mt5/mt5-art1.html" class="link1">MT5 and MQL 5 Development - questions and answers</a></font></div><div align=center><font class="ws9" face="MS Reference Sans Serif"><a href="http://www.fx1618.com/mt5/mt5-art2.html" class="link1">More Forex Profits With New MT5 Expert Advisors</a></font></div><div align=center><font class="ws9" face="MS Reference Sans Serif"><a href="http://www.fx1618.com/mt5/mt5-betarew.html" target="_blank" class="link1">Short Review of the Metatrader 5 beta</a></font></div><div align=center><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font class="ws12" face="MS Reference Sans Serif"><b>----------------------------</B></font></div><div align=center><font class="ws12" face="MS Reference Sans Serif"><b><br />
</B></font></div><div align=center><font class="ws16" color="#DF4800" face="MS Reference Sans Serif"> MetaQuotes Language 5 ( MQL 5)</font></div><div align=center><font class="ws11" face="MS Reference Sans Serif"><b><br />
</B></font></div><div><font class="ws9" face="MS Reference Sans Serif">The client terminal has its own built-in language for programming trading strategies - </font><font class="ws9" face="MS Reference Sans Serif"><b>MetaQuotes Language 5</B></font><font class="ws9" face="MS Reference Sans Serif">. This is the fifth generation of MQL languages. It allows writing Expert Advisors that automate management of trade processes, as well as implementing one's own trading strategies. Besides, custom indicators, scripts and function libraries can be created in MQL5.</font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif"><b>MQL5 Features:</B></font></div><div><font class="ws9" face="MS Reference Sans Serif">· The language is object-oriented; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· MQL5 syntax is similar to that of C++; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· It contains a large number of functions necessary for analyzing quotes, managing positions, calling technical indicators, etc.; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· The language is characterized by high performance; </font></div><div><font class="ws9" face="MS Reference Sans Serif">· It has the integrated development environment MetaEditor that includes a debugger. </font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif">The detailed description of all language constructions and functions can be found in MQL5 Userguide.</font></div><div><font class="ws12" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font face="MS Reference Sans Serif"><b><a href="http://www.fx1618.com/mt5/files/MQL5__User-Guide_translated.rar" class="link1">Download MQL 5 User Guide >>></a></B></font></div><div><font class="ws12" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font class="ws12" face="MS Reference Sans Serif"><b>----------------------------</B></font></div><div><font class="ws12" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font class="ws16" color="#DF4800" face="MS Reference Sans Serif">MetaEditor</font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif">MetaEditor is the MQL5 integrated development environment. It is a component part of the client terminal. MetaEditor allows to create, edit, compile and debug source program texts written in MQL5.</font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif"><b>· Editor Opening</B></font></div><div><font class="ws9" face="MS Reference Sans Serif">In order to open MetaEditor, one should execute " MetaQuotes Language Editor" command of the "Tools" menu or the "Standard" toolbar, or press F4. The editor can also be opened by executing the " Modify" command in the context menu of an Expert Advisor, indicator or script in the "Navigator" window. </font></div><div><font class="ws9" face="MS Reference Sans Serif"><b>· MQL5 Wizard</B></font></div><div><font class="ws9" face="MS Reference Sans Serif">MetaEditor has a built-in "MQL5 Wizard" that helps to quickly create MQL5 programs. The file is automatically saved in the corresponding folder of the client terminal. Templates can be used for creating files of MQL programs. </font></div><div><font class="ws9" face="MS Reference Sans Serif"><b>· Compilation</B></font></div><div><font class="ws9" face="MS Reference Sans Serif">After the program text has been written, it should be compiled. The successful compilation results in the creation of the program executable code that can be started or tested in the terminal. </font></div><div><font class="ws9" face="MS Reference Sans Serif"><b>· Debugging</B></font></div><div><font class="ws9" face="MS Reference Sans Serif">If an MQL5 program has a source code, it can be debugged using MetaEditor. </font></div><div><font class="ws9" face="MS Reference Sans Serif"><br />
</font></div><div><font class="ws9" face="MS Reference Sans Serif">More details about MetaEditor can be found in MetaEditor Userguide.</font></div><div><font class="ws12" face="MS Reference Sans Serif"><br />
</font></div><div align=center><font face="MS Reference Sans Serif"><b><a href="http://www.fx1618.com/mt5/files/Metaeditor5_User-Guide.rar" class="link1">Download Metaeditor 5 User Guide >>></a></B></font></div>mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-8307540015999152222010-10-14T08:52:00.000-07:002010-11-16T08:58:55.747-08:00Guide to Testing and Optimizing of Expert Advisors in MQL5<h3>Introduction<br /></h3><p style="text-align:justify;">Most of the time when a developer has written an Expert Advisor, making sure that the Expert Advisor achieves its aim of good profitability is always a very tasking process. In this article, we will look at some of the major steps needed in testing and optimizing an Expert Advisor so that we will be able to achieve close to the desired goal of writing the Expert Advisor. </p><h3><br /></h3><h3>1. Identifying and Correcting Code Crrors<br /></h3><p style="text-align:justify;">We will begin this article by looking at some common code errors normally encountered in the process of writing an Expert Advisor code. Most of the time beginners face some tough time identifying and correcting code errors when writing their codes or when modifying a code written by another developer. In this section we will look at how easy it is to use the MQL5 editor to identify and correct some of such errors.</p><p style="text-align:justify;">You have just completed writing the code and it seems everything should just work because you are almost certain that the code is error free. Or, it was a code that was written by someone else and you made a few changes and, alas! when you hit the <b>Compile</b> button (or press <b>F7</b>), you were presented by series of errors in the code as shown in the <b>Error</b> tab of the MetaEditor Toolbox window.</p><p style="text-align:center;"><img title="Compilation errors in an Expert Advisor code" alt="Compilation errors in an Expert Advisor code" src="http://p.mql5.com/data/2/156/compilation-errors-1__1.png" width="723" height="174" /></p><p style="text-align:center;"><span class="small">Figure 1. Compilation errors in an Expert Advisor code</span></p><p style="text-align:justify;">Wow! <b><span style="color:rgb(226, 8, 0);">38 errors and 1 warning</span></b>, your code may not have as much errors as shown here, all we want to look at are the various types of errors that are likely to show up when compiling our code and how we can resolve them. Let us describe the diagram above.</p><ul><li>The Section marked <b><span style="color:rgb(0, 67, 138);">1</span></b> shows the <b><i>description of the error in the code</i></b>. This is what gives us the idea of what the error looks like.</li>
<li>The section marked <span style="color:rgb(0, 67, 138);"><b>2 </b></span>shows us in <i><b>which file we have the error</b></i>. This is very important if we have included files that have errors. With this we will be able to know which file we are to check for the error described.</li>
<li>The section marked <b><span style="color:rgb(0, 67, 138);">3</span></b> shows us <b><i>which line and column (on the line) in our code the error is located</i></b>. This enables us to know which particular line to check for the error described.</li>
<li>The section marked <b><span style="color:rgb(0, 67, 138);">4</span></b> shows the <b><i>summary of the compilation errors and warnings.</i></b></li></ul><p style="text-align:justify;">Let us now begin to resolve the errors one after the other. Let us scroll up to the first line in the Error tab so that we can start from the beginning.</p><p style="text-align:center;"><img title="Identifying and resolving code errors-1" alt="Identifying and resolving code errors-1" src="http://p.mql5.com/data/2/156/compilation-errors-2__1.png" width="749" height="192" /></p><p style="text-align:center;"><span class="small">Figure 2. Identifying and resolving code errors</span></p><p style="text-align:justify;">The first issue is described as : <span></span>"<b>truncation of constant value</b>" and is discovered on <b>line 16 column 20</b>, to locate the exact line in our code, from the <b>Edit </b>menu of the MetaEditor, select <b>Go to Line</b> or press <b>CTRL G</b> on your keyboard.</p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small"><img alt="Figure 3. Locating the error code line number" title="Figure 3. Locating the error code line number" src="http://p.mql5.com/data/2/156/Image03__1.png" width="260" height="431" /><br /></span></p><p style="text-align:center;"><span class="small">Figure 3. Locating the error code line number</span></p><p>A dialog box will be displayed. </p><p style="text-align:center;"><img alt="Figure 4. Locating error line number dialog" title="Figure 4. Locating error line number dialog" src="http://p.mql5.com/data/2/156/Image04__1.png" width="271" height="142" /><br /></p><p style="text-align:center;"><span class="small">Figure 4. Locating error line number dialog</span></p><p style="text-align:justify;">The range of number as shown on the dialog box is the total number of lines in the code. In this case <b>(1-354) </b>shows that our code contains 354 lines of code. <br /></p><p style="text-align:justify;">Type the line number you want to check in the box and click the <b>OK</b> button. You will be taken straight to the line number in the code. <i><b>You will see the mouse cursor blinking on that particular line.</b></i></p><i><b></b></i><br />
<p style="text-align:center;"><i><b><img alt="Figure 5. Cursor showing the error line number" title="Figure 5. Cursor showing the error line number" src="http://p.mql5.com/data/2/156/Image05__1.png" width="594" height="180" /><br /></b></i></p><p style="text-align:center;"><span class="small">Figure 5. Cursor showing the error line number</span></p><p style="text-align:justify;">The problem here is that we declare <b>Lot</b> as an <b>integer </b>(<b>int</b>) variable but initialize it with a <b>double</b> value (<b>0.1</b>). To correct this error we will change the<b> int</b> to <b>double</b>, save the file and then click <b>COMPILE</b> button again to see if that has been corrected. </p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small"><img alt="Figure 6. Compile and save code after correction is made " title="Figure 6. Compile and save code after correction is made " src="http://p.mql5.com/data/2/156/Image06__1.png" width="434" height="175" /><br /></span></p><p style="text-align:center;"><span class="small">Figure 6. Compile and save code after correction is made </span></p><p style="text-align:justify;">On compiling again, the first issue has been resolved, but we still have more issues as shown below:</p><p style="text-align:center;"><img title="More errors in the code to resolve" alt="More errors in the code to resolve" src="http://p.mql5.com/data/2/156/compilation-errors-3__1.png" width="743" height="192" /></p><p style="text-align:center;"><span class="small">Figure 7. More errors shows up in code after compilation</span></p><p style="text-align:justify;">We will now follow the same procedure as above and go to line <b>31</b>. However, this time we will <u><b>right-click on the error</b></u> on the <b>Errors</b> tab and <u><b>select Go to line</b></u></p><p style="text-align:center;"><img title="Another way of locating code error line" alt="Another way of locating code error line" src="http://p.mql5.com/data/2/156/gotoline_menu2.png" width="749" height="198" /></p><p style="text-align:center;"><span class="small">Figure 8. Another way of locating code error line </span></p><p style="text-align:justify;">Or simply <b><u>select the error and hit the Enter button on your keyboard</u></b>. Immediately, you will be taken to the code line number <b>31</b>. <br /></p><p style="text-align:justify;">You will see the mouse cursor blinking and also a small round red button (error icon) on that particular code line 31.</p><p style="text-align:center;"><img title="Locating the code error line" alt="Locating the code error line" src="http://p.mql5.com/data/2/156/codeline-31__1.png" width="543" height="307" /></p><p style="text-align:center;"><span class="small">Figure 9a. Locating the code error line</span></p><p>However, if it is a warning message like the first one on line 16 that we corrected earlier, it will show a triangular yellow button (warning icon):</p><p style="text-align:center;"><img title="Warning sign" alt="Warning sign" src="http://p.mql5.com/data/2/156/warning_sign.png" width="294" height="59" /></p><p style="text-align:center;"><span class="small">Figure 9b. Locating the code error line</span></p><p style="text-align:justify;">It is very obvious that we don’t have any problem on line <b>31</b>, but the error description says: "<b>'STP' - unexpected token</b>" . <br /></p><p style="text-align:justify;">We then must check the previous code line (that is line 30) to see what may be wrong. On close examination, semicolon is missing after "<b><span style="color:rgb(44, 114, 199);">double</span> <span style="color:rgb(0, 0, 0);">ccminb</span> = <span style="color:rgb(0, 0, 0);">-</span><span style="color:rgb(0, 137, 44);">95.0000</span></b>" on line 30, that is why we have that error on line 31. We will now fix this error by typing the semicolon after -<span style="color:rgb(0, 137, 44);"><b>95.0000</b></span> and compile the code again.</p><p style="text-align:justify;">Now the line <b>31</b> errors are gone. Next is line <b>100</b> as shown below:</p><p style="text-align:center;"><img title="More errors still exist in code" alt="More errors still exist in code" src="http://p.mql5.com/data/2/156/compilation-errors-4__1.png" width="738" height="187" /></p><p style="text-align:center;"><span class="small">Figure 10. More errors still exist in code</span></p><div class="fquote"><p style="text-align:justify;">Hey Olowsam, must we be compiling after each correction, why don’t we just go to through all the lines at the same time and after we have done all the corrections then we compile the code once instead of compiling after each correction?</p></div><p style="text-align:justify;"><b>Did you just ask this question?</b></p><p style="text-align:justify;">You may be right in a way, but I will not advise that. Problems are always resolved one after the other – Step by Step. Any attempt to lump problem together and solve them at once may lead to many headaches. You will soon understand why… just be patient with me.</p><p style="text-align:justify;">Back to our problem, we are to check line 100 for the next error. The error states : "<b>'if' - expressions are not allowed on a global scope</b>" And I am sure that the if expression in line 100 is not on a global scope, but why are we having this error. Please let us go to line 100.</p><p style="text-align:center;"><img alt="Figure 11. Locating the error in the code" title="Figure 11. Locating the error in the code" src="http://p.mql5.com/data/2/156/codeline-100__1.png" width="689" height="120" /><br /></p><p style="text-align:center;"><span class="small">Figure 11. Locating the error in the code</span></p><p style="text-align:justify;">We can't find any problem on line 100 and because we just finished correction line 31, we are sure that the problem now is between line 32 and line 99. So let us move upward to line 99 (we have a comment , so it can't be the error). If we also look upwards to the declarations (<a target="_blank" href="/en/docs/constants/structures/mqltick">MqlTick</a>, <a target="_blank" href="/en/docs/constants/structures/mqltraderesult">MqlTradeRequest </a>and <a target="_blank" href="/en/docs/constants/structures/mqltraderesult">MqlTradeResult</a>), they are correctly declared and punctuated.</p><p style="text-align:justify;">Next let us look at the code for the <b>if</b> expression before these declaration code lines and see if the expression is okay.<span> </span>On very close study, we discover that the if expression has a closing brace, but no opening brace.</p><p style="text-align:center;"><img alt="Figure 12. Looking above the error line number to identify error" title="Figure 12. Looking above the error line number to identify error" src="http://p.mql5.com/data/2/156/if-code-error.png" width="680" height="290" /><br /></p><p style="text-align:center;"><span class="small">Figure 12. Looking above the error line number to identify error</span></p><p>Add the opening brace and compile the code again.</p><pre class="code"><span class="comment">//--- Do we have enough bars to work with</span>
<span class="keyword">int</span> Mybars=<span class="functions">Bars</span>(<span>_Symbol</span>,<span>_Period</span>);
<span class="keyword">if</span>(Mybars<<span class="number">60</span>) <span class="comment">// if total bars is less than 60 bars
</span> {
<span class="functions">Alert</span>(<span class="string">"We have less than 60 bars, EA will now exit!!"</span>);
<span class="keyword">return</span>;
}</pre><p>Once the code was compiled; errors on line <b>100, 107, 121, 126, 129, </b>etc were completely cleared and new ones show up. See why it is good to follow step by step? </p><p style="text-align:center;"><img title="More errors show up in code" alt="More errors show up in code" src="http://p.mql5.com/data/2/156/compilation-errors-5__3.png" width="747" height="189" /></p><p style="text-align:center;"><span class="small">Figure 13. More errors still exist in code</span></p><p style="text-align:justify;">Next we move to line <b>56</b> with two errors : "<b>'cciVal1' - parameter conversion is not allowed</b>" and "<b>'cciVal1' - array is required</b>"</p><p style="text-align:justify;">On closer look at line <b>56</b>, <b>cciVal1</b> is supposed to have been declared as an array. <i><b>Could it be that we did not declare it as an array but now trying to use it as an array?</b></i> Let us check the declaration section to confirm this before we can know what next to do.</p><pre class="code"><span class="comment">//--- Other parameters</span>
<span class="keyword">int</span> maHandle; <span class="comment">// handle for our Moving Average indicator</span>
<span class="keyword">int</span> cciHandle1,cciHandle2; <span class="comment">// handle for our CCI indicator</span>
<span class="keyword">double</span> maVal[]; <span class="comment">// Dynamic array to hold the values of Moving Average for each bars</span>
<span class="keyword">double</span> cciVal1,cciVal2[]; <span class="comment">// Dynamic array to hold the values of CCI for each bars</span>
<span class="keyword">double</span> p1_close,p2_close; <span class="comment">// Variable to store the close value of Bar 1 and Bar 2 respectively</span></pre><p style="text-align:justify;">From, here, we can see that we mistakenly declare <b>cciVal1</b> as a double rather than as a dynamic array because we omitted the square brackets (<b>[]</b>). Let us add the square brackets (just as we have for <b>cciVal2[]</b>) and then compile the code.</p><pre class="code"><span class="comment">//--- Other parameters</span>
<span class="keyword">int</span> maHandle; <span class="comment">// handle for our Moving Average indicator</span>
<span class="keyword">int</span> cciHandle1,cciHandle2; <span class="comment">// handle for our CCI indicator</span>
<span class="keyword">double</span> maVal[]; <span class="comment">// Dynamic array to hold the values of Moving Average for each bars</span>
<span class="keyword">double</span> cciVal1[],cciVal2[]; <span class="comment">// Dynamic array to hold the values of CCI for each bars</span>
<span class="keyword">double</span> p1_close,p2_close; <span class="comment">// Variable to store the close value of Bar 1 and Bar 2 respectively</span></pre><p style="text-align:center;"><img title="Errors in code reduced considerably" alt="Errors in code reduced considerably" src="http://p.mql5.com/data/2/156/compilation-errors-6__1.png" width="738" height="186" /></p><p style="text-align:center;"><span class="small">Figure 14. Errors in code has been reduced considerably</span></p><p style="text-align:justify;">What! So many errors have disappeared. We only corrected error reported on line <b>56 </b>and some other errors were resolved automatically. This is because, the error reported on line <b>56</b> was responsible for those other errors. <b>This is why it is good to follow a step by step process in resolving errors in your code.</b></p><p style="text-align:justify;">We will now move to the next reported error on line <b>103</b> : "<b>'GetLastError' - undeclared identifier</b>"<span> </span>Wait a minute, <b>GetLastError</b> is supposed to be a function… Let go to line <b>103 </b>to see what the problem is.</p><pre class="code"><span class="comment">//--- Get the last price quote using the MQL5 MqlTick Structure</span>
<span class="keyword">if</span>(!<span class="functions">SymbolInfoTick</span>(<span>_Symbol</span>,latest_price))
{
<span class="functions">Alert</span>(<span class="string">"Error getting the latest price quote - error:"</span>,<span class="functions">GetLastError</span>,<span class="string">"!!"</span>); <span class="comment">// line 103</span>
<span class="keyword">return</span>;
}
</pre><p style="text-align:justify;">The problem is actually on line <b>103</b>. <b>GetLastError</b> is a function and every function needs a pair of parenthesis for input parameters. Let us type an empty pair of parenthesis and then compile the code. The empty pair of parenthesis indicates that the function takes no arguments or parameters.</p><pre class="code"><span class="comment">//--- Get the last price quote using the MQL5 MqlTick Structure</span>
<span class="keyword">if</span>(!<span class="functions">SymbolInfoTick</span>(<span>_Symbol</span>,latest_price))
{
<span class="functions">Alert</span>(<span class="string">"Error getting the latest price quote - error:"</span>,<span class="functions">GetLastError</span>(),<span class="string">"!!"</span>); <span class="comment">// line 103</span>
<span class="keyword">return</span>;
}
</pre><p style="text-align:justify;">Next, we move to line <b>159</b> : "<b>'=' - l-value required</b>" <span> </span>and<span> </span>a warning : "<b>expression is not Boolean</b>" Let us go to line <b>159</b> and see what this error means. </p><pre class="code"> <span class="keyword">else</span> <span class="keyword">if</span>(<span class="functions">PositionGetInteger</span>(<span class="keyword">POSITION_TYPE</span>) = <span class="keyword">POSITION_TYPE_SELL</span>) <span class="comment">// line 159</span>
{
Sell_opened = true; <span class="comment">// It is a Sell</span></pre><p style="text-align:justify;">It can be seen here that we assigned the value of <a target="_blank" href="/en/docs/constants/tradingconstants/positionproperties#enum_position_property_integer">POSITION_TYPE_SELL</a> to<span> </span><a target="_blank" href="/en/docs/trading/positiongetinteger">PositionGetInteger</a><a target="_blank" href="/en/docs/trading/positiongetinteger">(POSITION_TYPE)</a> in the if statement and this is not what we intend to do. We wanted to make comparison instead. We will now change the expression to use <b><a href="/en/docs/basis/operations/relation" target="_blank">equal operator</a></b> rather than using an <b><a href="/en/docs/basis/operations/assign" target="_blank">assignment operator</a></b>. (that is ‘==’ instead of ‘=’). Make the correction and compile the code.</p><pre class="code"> <span class="keyword">else</span> <span class="keyword">if</span>(<span class="functions">PositionGetInteger</span>(<span class="keyword">POSITION_TYPE</span>) == <span class="keyword">POSITION_TYPE_SELL</span>) <span class="comment">// line 159</span>
{
Sell_opened = true; <span class="comment">// It is a Sell</span></pre><p style="text-align:justify;">Good! Now we have one more to go. Let us go to line <b>292</b> to see why it says "<b>'PositionsTotal' - undeclared identifier</b>" . Wait a minute, can you remember that we have seen an error like this before? ‘<b>GetlastError</b>’ line <b>103</b>. Possibly, we forget to add the pair of parenthesis for PositionsTotal<span> </span>too, since it is a function. Let us go to line <b>292</b> to confirm.</p><pre class="code"><span class="keyword">bool</span> CheckTrade(<span class="keyword">string</span> otyp)
{
<span class="keyword">bool</span> marker = <span class="keyword">false</span>;
<span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">1</span>; i<=PositionsTotal;i++) <span class="comment">// line 292</span>
{</pre><p style="text-align:justify;">Just like we suspected, it is because we forgot to add the pair of parenthesis for the function <b>PositionsTotal</b>. Now add the pair of parenthesis (<b>PositionsTotal()</b>) and compile the code. Let me also state that, it is possible to get this error if we actually use a variable which we did not declare anywhere in the code.</p><p style="text-align:center;"><img alt="Figure 15. All compilation Errors has been completely resolved" title="Figure 15. All compilation Errors has been completely resolved" src="http://p.mql5.com/data/2/156/Image15__1.png" width="575" height="138" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 15. All compilation Errors has been completely resolved</span></p><p style="text-align:justify;">Wonderful! Now we have been able to correct all the compilation errors. It is now time to debug our code and see if there are run-time errors. Here, we will not be going into the details of how to debug our code as it has already been explained in <b><u><a href="/en/articles/100" target="_blank">this article.</a></u></b></p><p></p><p style="text-align:justify;">As the debug session begins, we notice another error :</p><p style="text-align:center;"><img alt="Figure 16. Runtime error observed during debugging of code" title="Figure 16. Runtime error observed during debugging of code" src="http://p.mql5.com/data/2/156/Image16__1.png" width="682" height="315" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 16. Runtime error observed during debugging of code</span></p><p>Click the <b>OK</b> button and you will be taken to the line of code that generates the error.</p><p style="text-align:center;"><img title="Identifying the line of code that generates run-time error" alt="Identifying the line of code that generates run-time error" src="http://p.mql5.com/data/2/156/debug-error-1-location__1.png" width="616" height="191" /></p><p style="text-align:center;"><span class="small">Figure 17. Identifying the line of code that generates run-time error</span></p><p style="text-align:justify;">The error is generated by this code on line <b>172</b> as you can see from the figure above. Since the error is an "<b>Array out of range</b>" error, it means that the value we intend to get from the array is out of the range of the array values available. So we will now go to the line where we copy the indicator buffers into arrays to see what the problem is.</p><pre class="code"><span class="comment">//--- Copy the new values of our indicators to buffers (arrays) using the handle</span>
<span class="keyword">if</span>(<span class="functions">CopyBuffer</span>(maHandle,<span class="number">0</span>,<span class="number">0</span>,<span class="number">3</span>,maVal)<<span class="number">0</span>)
{
<span class="functions">Alert</span>(<span class="string">"Error copying MA indicator Buffers - error:"</span>,<span class="functions">GetLastError</span>(),<span class="string">"!!"</span>);
<span class="keyword">return</span>;
}
<span class="keyword">if</span>(<span class="functions">CopyBuffer</span>(cciHandle1,<span class="number">0</span>,<span class="number">0</span>,<span class="number">3</span>,cciVal1)<<span class="number">0</span> || <span class="functions">CopyBuffer</span>(cciHandle2,<span class="number">0</span>,<span class="number">0</span>,<span class="number">3</span>,cciVal2)<<span class="number">0</span>)
{
<span class="functions">Alert</span>(<span class="string">"Error copying CCI indicator buffer - error:"</span>,<span class="functions">GetLastError</span>());
<span class="keyword">return</span>;
}</pre><p style="text-align:justify;">We can observe from the <a href="/en/docs/series/copybuffer" target="_blank">CopyBuffer</a> functions that we have only copied three values (Bar 0, 1, and 2) which means that we can only access array values of <b>maVal[0]</b>, <span> </span><b>maVal[1]</b>, <span> </span>and <b>maVal[2]</b> and also <b>cciVal1[0]</b> , <b>cciVal1[1]</b> <span> </span>and <b>cciVal1[2]</b>, etc. But in our code on line <b>172</b>, we were trying to get the array value for <b>cciVal1[3]</b>. This is why the error was generated. <span> </span>Now, stop the debugger so that we can fix the error:</p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small"><img alt="Figure 18. Stop debugger to correct error in code" title="Figure 18. Stop debugger to correct error in code" src="http://p.mql5.com/data/2/156/Image18__1.png" width="334" height="68" /><br /></span></p><p style="text-align:center;"><span class="small">Figure 18. Stop debugger to correct error in code</span></p><p style="text-align:justify;">To fix this we need to increase the number of records to be copied from Indicator buffers to <b>5</b> so that we will be able to obtain array values of <b>cciVal1[0], cciVal1[1], cciVal1[2], cciVal1[3],</b> and <b>cciVal1[4]</b> if need be.</p><pre class="code"><span class="comment">//--- Copy the new values of our indicators to buffers (arrays) using the handle</span>
<span class="keyword">if</span>(<span class="functions">CopyBuffer</span>(maHandle,<span class="number">0</span>,<span class="number">0</span>,<span class="number">5</span>,maVal)<<span class="number">0</span>)
{
<span class="functions">Alert</span>(<span class="string">"Error copying MA indicator Buffers - error:"</span>,<span class="functions">GetLastError</span>(),<span class="string">"!!"</span>);
<span class="keyword">return</span>;
}
<span class="keyword">if</span>(<span class="functions">CopyBuffer</span>(cciHandle1,<span class="number">0</span>,<span class="number">0</span>,<span class="number">5</span>,cciVal1)<<span class="number">0</span> || <span class="functions">CopyBuffer</span>(cciHandle2,<span class="number">0</span>,<span class="number">0</span>,<span class="number">5</span>,cciVal2)<<span class="number">0</span>)
{
<span class="functions">Alert</span>(<span class="string">"Error copying CCI indicator buffer - error:"</span>,<span class="functions">GetLastError</span>());
<span class="keyword">return</span>;
}</pre><p>Correct the code as shown and then start the debugger again. This time, no more errors as we notice our Expert Advisor performing trade actions</p><p style="text-align:center;"><img alt="Figure 19. All errors corrected, Expert Advisor performs trade during debugging" title="Figure 19. All errors corrected, Expert Advisor performs trade during debugging" src="http://p.mql5.com/data/2/156/Image19.png" width="731" height="531" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 19. All errors corrected, Expert Advisor performs trade during debugging</span></p><p> </p><h3>2. Testing the Expert Advisor<br /></h3><p style="text-align:justify;">Once we are sure that our code is error free, it is now time to test the Expert Advisor to be able to get the best settings that will give us the best results. In order to carry out the test, we will use the Strategy Tester, a program which is built into the MetaTrader<span> </span>terminal. To launch the Strategy Tester, Go to <b>View</b> menu on the Terminal and select <b>Strategy Tester</b>.</p><p style="text-align:center;"><img alt="Figure 20. Launching the Strategy Tester" title="Figure 20. Launching the Strategy Tester" src="http://p.mql5.com/data/2/156/Image20__1.png" width="208" height="294" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 20. Launching the Strategy Tester</span></p><p style="text-align:justify;"><b>2.1. Preliminary Testing of our Expert Advisor</b><br /><br />
</p><p style="text-align:justify;">At this point, we want to test our Expert using the available symbols in the Market Window. With this result we will be able to guess which currency pairs we can better optimize our Expert for. Make sure the Market Window contains most of the currencies you are targeting for the Expert. </p><p style="text-align:justify;">Select the Expert on the Strategy Tester <b>Settings</b> Tab, select the period/timeframe you have in mind (and of course you can also test it for different timeframes) and then Select '<b>All Symbols Selected in MARKET Watch</b>' in the optimization field. Directly in-front is the Optimization results parameter, select <b>Balance + max Profit Factor</b>.</p><p style="text-align:center;"><img alt="Figure 34. Preliminary test of Expert Advisor with all symbols in the Market Watch window " title="Figure 34. Preliminary test of Expert Advisor with all symbols in the Market Watch window " src="http://p.mql5.com/data/2/156/Image34__1.png" width="746" height="573" /><br /></p><p style="text-align:center;"><span></span></p><p style="text-align:center;"><span class="small">Figure 21. Preliminary test of Expert Advisor with all symbols in the Market Watch window </span></p><p style="text-align:justify;"><b>1. Select the tick generation mode –(Every Tick)</b></p><p style="text-align:justify;"><b>2. Select Optimization Type –(All Symbols Selected in MARKET Watch)</b></p><p style="text-align:justify;"><b>3. Select type of expected Result from optimization</b> </p><p style="text-align:justify;">You can get the details of the various optimization types from the terminal help documentation. We are not forward testing, so leave <b>Forward</b> as <b>No</b>.</p><p style="text-align:justify;">For this test, the main values/parameters (highlighted in green) in the <b>Inputs</b> tab will be used.</p><p style="text-align:center;"><img alt="Figure 35. Preliminary test input parameters" title="Figure 35. Preliminary test input parameters" src="http://p.mql5.com/data/2/156/Image35__1.png" width="715" height="172" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 22. Preliminary test input parameters</span></p><p>Once you are done, switch over to the <b>Settings</b> tab and click the <b>Start</b> button. On completion of the test, you will see a message in the Journal Tab similar to the following:</p><p style="text-align:center;"><img alt="Figure 36. Preliminary test completed" title="Figure 36. Preliminary test completed" src="http://p.mql5.com/data/2/156/Image36__1.png" width="581" height="218" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 23. Preliminary test completed</span></p><p>Once the test is completed, go to the <b>Optimization Results </b>Tab to see the results.</p><p style="text-align:center;"><img alt="Figure 37. Preliminary test optimization results" title="Figure 37. Preliminary test optimization results" src="http://p.mql5.com/data/2/156/Image37__1.png" width="750" height="198" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 24. Preliminary test optimization results</span></p><p style="text-align:justify;">Our interest is in the symbol that gives the highest Result based on our setting – (<b>Balance + max Profit Factor</b>). To get this, let us sort the result by clicking on the <b>Result </b>title such that the symbol with the highest result is listed at the top.</p><p style="text-align:center;"><img alt="Figure 38. Preliminary optimization result analysis" title="Figure 38. Preliminary optimization result analysis" src="http://p.mql5.com/data/2/156/Image38__1.png" width="748" height="197" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 25. Preliminary optimization result analysis</span></p><p style="text-align:justify;">From this result, we can see that our Expert Advisor can be profitable for the following symbols (<b>EURUSD, EURJPY, AUDUSD</b>) in the timeframe we have selected. <span> </span>You can further perform this test for another timeframe, say, 30mins and see what you have. This should be taken as an assignment and please share the result so that we can all learn too.</p><p style="text-align:justify;">From the result of our preliminary test, we will now decide which symbol(s) and timeframe(s) we are going to optimize our Expert Advisor for. </p><p style="text-align:justify;">In this example, we will optimize our Expert Advisor for the <b>EURUSD</b> and <b>1 Hour </b>timeframe.<span> </span>What are the things that motivate the choice we just made:</p><ul><li><b>Profit Factor:</b></li></ul><p style="text-align:justify;">The Profit factor is the ratio of the total profit to that total loss for that test. The higher the Profit factor the more profitable your trading strategy is. </p><ul><li><b>Drawdown %:</b></li></ul><p style="text-align:justify;">This refers to the relative drawdown of the equity or the largest loss (in percent) from the maximal value of equity. The lower the Drawdown (in percent), the better the strategy.</p><ul><li><b>Recovery Factor:</b></li></ul><p style="text-align:justify;">This is the ratio of the profit to the maximal drawdown. It reflects the riskiness of the trading strategy. </p><p style="text-align:justify;">Having decided on the symbol and timeframe to use, it is now time to optimize our Expert Advisor.</p><p style="text-align:justify;"><b>2.2. Optimizing the Expert Advisor</b></p><p style="text-align:justify;">Optimization is simply a process of fine-tuning the performance of our EA by testing with various factors (parameters) that determines the effectiveness or profitability of our Strategy coded in the EA. It is a similar procedure to testing, but instead of testing the EA only once, it will be tested many times depending on the parameters selected in the Input tab.</p><p style="text-align:justify;">To begin, we go to the settings tab and enable optimization and then select the type of result we want from our optimization.</p><p style="text-align:center;"><img alt="Figure 39. Optimization settings for Expert Advisor" title="Figure 39. Optimization settings for Expert Advisor" src="http://p.mql5.com/data/2/156/Image39__1.png" width="749" height="266" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 26. Optimization settings for Expert Advisor</span></p><p style="text-align:justify;"><b>1. Select the tick generation mode –(Every Tick)</b></p><p style="text-align:justify;"><b>2. Select Optimization Type –(Fast Genetic Based Algorithm)</b></p><p style="text-align:justify;"><b>3. Select type of expected Result from optimization </b>(here we select <b>Balance + Max Profit Factor</b>)</p><p style="text-align:justify;">You can get the details of the various optimization types from the terminal help documentation. We are not forward testing, so leave Forward as No. Having set the optimization properties, let us set the parameters to be used for the optimization in the<b> Inputs</b> tab.</p><p style="text-align:center;"><img alt="Figure 40. Optimization Input parameters" title="Figure 40. Optimization Input parameters" src="http://p.mql5.com/data/2/156/Image40__1.png" width="729" height="206" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 27. Optimization Input parameters</span></p><p style="text-align:justify;">Since we are optimizing, we will only concentrate on the areas highlighted in yellow. First of all, any parameter we do not want to use in the optimization must be unchecked. In order words, we will only check the parameters we want to use in the optimization of the EA. Here, I have checked five parameters, but you may decide to check only one or two depending on the parameters that the effectiveness of your strategy is based on. For example, you may check only the Moving Average and CCI periods such that the optimization result will let you know the best value for each of the Indicators that give your EA the best performance. This is the main essence of optimizing.</p><p style="text-align:justify;">Also, the number of parameters checked will determine the total number of tests that your EA will go through. You will soon see what I am talking about.</p><p style="text-align:justify;"><b><u>Setting The Values</u></b></p><p style="text-align:justify;"><b><i>Start: </i></b></p><p style="text-align:justify;">This is the starting value to be used for the selected variable for optimization.<span> </span>Let us use the Stop Loss variable to explain how to set the values. For the Stop Loss, we have asked the tester to start with a value of <b>30</b>. This will be the minimum value that will be used for Stop Loss during the optimization.</p><p style="text-align:justify;"><b><i>Step:</i></b></p><p style="text-align:justify;">This is the incremental value for the Stop Loss. If we set an increment of 2; it means that, if in the first test, it uses <b>30</b> for Stop Loss it will use either <b>32, 36, 34</b> etc. in the second… It does not mean that it will use <b>30</b>, then followed by <b>32</b>, <b>34</b> etc. No, it selects the values at random but they will always be multiples of two (2) between the Start value and the Stop value. </p><p style="text-align:justify;"><b><i>Stop:</i></b></p><p style="text-align:justify;">This is the maximum or highest value that will be used for the optimization. Here we specified <b>38</b>. This means that the values that will be used for the testing will be between <b>30</b> and <b>38</b> but will be values which are multiples of <b>2</b>. It will not use <b>40</b> or any value greater.</p><p style="text-align:justify;">The total number of tests that will be carried out depends on the settings of these three sections. In our example, the tester will combine a total of <b>5</b> possibilities alone for the Stop Loss as shown in the <b><i>Steps</i></b> column on the <b>Inputs </b>Tab, it will combine a total of 8 possibilities for the Take Profit, etc. By the time you consider all the other variables, it will be getting to hundreds or thousands of possibilities (tests/passes). If you don't want to wait for ages in order to optimize a single EA, make sure you don't include or check too many variables; maybe just two or three that the performance of your EA really depends on (most especially, the indicator periods, if you use them in your own code). Also you must make sure your step value will not result in having too many possibilities (tests). For example, if we use <b>1</b> as the step value, then we have increased the number of attempts for the Stop Loss alone to <b>10</b>. Well, as said earlier, the total time required to complete an optimization session depends on the total number of available agents you have setup on your system.</p><p style="text-align:justify;">I believe the explanation is sufficient. </p><p style="text-align:justify;">Once we have finished setting the inputs, we now go back to the Settings tab and click the <b>Start</b> Button.</p><br />
<p style="text-align:center;"></p><p>Once the optimization is completed, we can see the details on the journal tab.</p><p style="text-align:center;"><img alt="Figure 43. Optimization completed as shown in the Journal tab" title="Figure 43. Optimization completed as shown in the Journal tab" src="http://p.mql5.com/data/2/156/Image43__1.png" width="658" height="265" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 28. Optimization completed as shown in the Journal tab</span></p><p style="text-align:justify;">To view the results as each test is passed or completed, we go to the <b>Optimization Results</b> tab. And it is always good to sort the output by the Results so that we can easily identify the settings that gives us the best result based on our optimization setting. Clicking on the <b>Result</b> heading within the <b>optimization Results</b> tab will arrange the results in either ascending or descending order</p><p style="text-align:center;"><img alt="Figure 44. Optimization report" title="Figure 44. Optimization report" src="http://p.mql5.com/data/2/156/Image44__1.png" width="746" height="367" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 29. Optimization report</span></p><p>Switch over to the <b>Optimization Graph</b> tab to see how the graph looks like.</p><p style="text-align:center;"><img alt="Figure 45. Optimization graph" title="Figure 45. Optimization graph" src="http://p.mql5.com/data/2/156/Image45__1.png" width="730" height="262" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 30. Optimization graph</span></p><p style="text-align:justify;">Don’t understand what you see? Don’t worry; the dots you see is a plot of the number of tests your EA passed against the optimization result based on the optimization result type you selected. In our case we selected Balance + max Profit factor.</p><p><b>2.3. Interpreting the result</b></p><p style="text-align:justify;">To successfully interpret the optimization report, go to the Optimization Results tab. You will discover that you cannot see some fields like, Profit factor, Expected Payoff, Drawdown %, etc . To see them, right-click anywhere in the <b>Optimization Results</b> tab and select the additional information you wish to see as shown below:</p><p style="text-align:center;"><img alt="Figure 46. Selecting Drawdown% in optimization result" title="Figure 46. Selecting Drawdown% in optimization result" src="http://p.mql5.com/data/2/156/Image46__1.png" width="178" height="244" /><br /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 31. Selecting Drawdown% in optimization result</span></p><p style="text-align:center;"> <img alt="Figure 47. Selecting Profit Factor in optimization result" title="Figure 47. Selecting Profit Factor in optimization result" src="http://p.mql5.com/data/2/156/Image47__2.png" width="178" height="244" /></p><p style="text-align:center;"></p><p style="text-align:center;"><span class="small">Figure 32. Selecting Profit Factor in optimization result</span></p><p>Having added these additional records, we will now analyze the Optimization result to decide the best settings for our Expert Advisor.</p><p style="text-align:center;"><img title="Optimization report Analysis" alt="Optimization report Analysis" src="http://p.mql5.com/data/2/156/optimization-result-analysis-1.png" width="748" height="356" /></p><p style="text-align:center;"><span class="small">Figure 33. Analyzing the optimization result</span></p><p style="text-align:justify;">From the above figure, the highlighted sections labeled A and B indicates the best results for our Expert Advisor. <span> </span>Now the choice you make is completely yours, It all depends on what you are looking for. However, here we are interested not only in the settings that give the highest profit, but also have a lower <b>drawdown%.</b> <br /></p><p style="text-align:justify;">As you can see, the section <b>A</b> (highlighted in yellow) has the best result (<b>Balance + max Profit Factor</b>) of <b>22381.71</b> with a profit of <b>924.10</b> while the section <b>B</b> (highlighted in green) has the second best result of <b>22159.25</b> but with a higher profit of <b>936.55</b>. Section <b>A</b> had a lower <b>Drawdown%</b> of <b>1.78</b> while B has a higher drawdown of <b>1.95</b>.</p><p style="text-align:justify;">The Strategy Tester saves the optimization results to the"<Client terminal data folder>\Tester\cache" folder. In your case all the optimization data will be saved to the cci_ma_ea.EURUSD.H1.0.xml file,<br /></p><p style="text-align:justify;">The file name has the following form: ExpertName.SYMBOL.PERIOD.GenerationMode.xml, where:</p><ul><li>ExpertName - Expert Advisor Name;<br /></li><li>Symbol - symbol;<br /></li><li>Period - timeframe (M1,H1,...)</li><li>GenerationMode - tick generation mode (0-every tick, 1 - one minute OHLC, 2 - open prices only).<br /></li></ul><p style="text-align:justify;">The XML files can be opened by MS Excel.<br /></p><p></p><p><b>2.4. Choosing the Best Result<br /></b></p><p>To finally obtain the best result, we need to look at the Optimization graph again. Switch back to the Optimization graph.<span> </span>Right-click anywhere within the graph and select<span> </span><b>1D Graph. </b></p><p style="text-align:center;"><img title="Select 1-D graph form optimization graph" alt="Select 1-D graph form optimization graph" src="http://p.mql5.com/data/2/156/optimization-graph-select1d.png" width="485" height="297" /></p><p style="text-align:center;"><span class="small">Figure 34. Select 1-dimensional (1 D) graph for result analysis</span></p><p style="text-align:justify;">With this we can easily see the values of each of the input parameters that give the best result. <span> </span>You can now begin to choose each parameter to be able to see the best value. Right-click on the graph and select <b>X-Axis</b> and then select the parameter you want to check. It will look like below (for Stop loss)</p><p style="text-align:center;"><img alt="Figure 50. Getting the best StopLoss value from the optimization result" title="Figure 50. Getting the best StopLoss value from the optimization result" src="http://p.mql5.com/data/2/156/Image50__1.png" width="746" height="356" /><br /></p><p style="text-align:center;"><span class="small">Figure 35. Getting the best StopLoss value from the optimization result</span></p><p style="text-align:justify;">Actually, from the optimization result, it is very clear that the best Stoploss is 34, the best TakeProfit is 78, and the best CCI_Period1 is 62. To obtain the best values for the MAPeriod and CCI_Period2, select each of them as above</p><p style="text-align:center;"><img alt="Figure 51. Getting the best Moving Average Period value from the optimization result" title="Figure 51. Getting the best Moving Average Period value from the optimization result" src="http://p.mql5.com/data/2/156/Image51__1.png" width="746" height="253" /><br /></p><p style="text-align:center;"><span class="small">Figure 36. Getting the best Moving Average Period value from the optimization result</span></p><p style="text-align:justify;">This graph shows a value of <b>26</b> as the MA_Period with the best result.</p><p style="text-align:center;"><img alt="Figure 52. Getting the best CCI_Period1 value from the optimization result" title="Figure 52. Getting the best CCI_Period1 value from the optimization result" src="http://p.mql5.com/data/2/156/Image52__1.png" width="742" height="253" /><br /></p><p style="text-align:center;"><span class="small">Figure 37. Getting the best CCI_Period1 value from the optimization result</span></p><p style="text-align:justify;">This graph shows a value of <b>62</b> as the CCI_Period1 with the best result.</p><p style="text-align:center;"><img alt="Figure 53. Getting the best CCI_Period2 value from the optimization result" title="Figure 53. Getting the best CCI_Period2 value from the optimization result" src="http://p.mql5.com/data/2/156/Image53__1.png" width="743" height="254" /><br /></p><p style="text-align:center;"><span class="small">Figure 38. Getting the best CCI_Period2 value from the optimization result</span></p><p style="text-align:justify;">This graph shows values of <b>28</b> or <b>30</b> as the CCI_Period2 with the best results.</p><p style="text-align:justify;">Having obtained the best values for each parameter, it is now time for the final testing of our Expert Advisor.</p><p style="text-align:justify;"><b>2.5. The Final Test</b></p><p style="text-align:justify;">The final test involves putting together the best parameters for the testing of the Expert Advisor. In this case, we will use the best values we discovered in the INPUT section of the Strategy Tester as shown below.</p><p style="text-align:center;"><img title="Input values for the final test" alt="Input values for the final test" src="http://p.mql5.com/data/2/156/final-result-inputs.png" width="658" height="203" /></p><p style="text-align:center;"><span class="small">Figure 39. The final test input parameters</span></p><p>In the <b>SETTINGS</b> tab of the Strategy Tester, we will disable Optimization as shown below</p><p style="text-align:center;"><img title="The settings for the final test" alt="The settings for the final test" src="http://p.mql5.com/data/2/156/final-result-settings.png" width="745" height="245" /></p><p style="text-align:center;"><span class="small">Figure 40. The final test settings</span></p><p>We will now click the <b>START</b> button to begin the test. Once the test is completed, we have the results on the <b>RESULTS</b> tab as shown below</p><p style="text-align:center;"><img alt="Figure 56. The final test results" title="Figure 56. The final test results" src="http://p.mql5.com/data/2/156/Image56__1.png" width="723" height="285" /><br /></p><p style="text-align:center;"><span class="small">Figure 41. The final test results</span></p><p>And likewise, we have the graph for the test on the <b>GRAPH</b> tab</p><p style="text-align:center;"><img alt="Figure 57. The final test graph result" title="Figure 57. The final test graph result" src="http://p.mql5.com/data/2/156/Image57__1.png" width="746" height="295" /><br /></p><p style="text-align:center;"><span class="small">Figure 42. The final test graph result</span></p><h3><b>Conclusion</b><br /></h3><p style="text-align:justify;">In this article, we have discussed the ways to identify and correct code errors and we have also discussed how to test and optimize an Expert Advisor for the best symbol from the market watch. <br /></p><p style="text-align:justify;">With this article, I believe checking code for errors using the editor and optimizing and testing of Expert Advisors using the Strategy Tester makes writing a better and profitable Expert Advisor possible.</p>mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-78119275370027881752010-09-25T08:42:00.000-07:002010-11-16T08:52:08.964-08:00Better Linux compatibility with MetaTrader 5I noticed that installing winetricks and then allfonts and gdiplus packages additional to wine 1.3.5 improves MetaTrader 5 look and feel.<br />
<br />
Steps:<br />
<br />
1) Install winetricks<br />
<br />
http://wiki.winehq.org/winetricks<br />
<br />
2) Install allfonts from winetricks<br />
<br />
$ winetricks allfonts<br />
<br />
3) Install gdiplus from winetricks<br />
<br />
$ winetricks gdiplusmql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-84053856268517265852010-09-21T08:40:00.000-07:002010-11-16T08:51:37.091-08:00Improved access to historical quotes Metatrader 5Those 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.<br />
<br />
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.<br />
<br />
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.<br />
<br />
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.mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-17532293839552899882010-09-20T08:39:00.000-07:002010-11-16T08:51:16.177-08:00MQL4 and MQL5: Differences at a glanceMQL5 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.<br />
<br />
The differences appear at first sight mql5 code are: <br />
<br />
In mql5 not have to declare the functions start (), init () and deinit () (function start () was essential for in MQL4). <br />
<br />
The number of buffers in the indicators are not limited (in MQL4 the maximum amount of buffers for an indicator was 8). <br />
<br />
Mql5 provides automatic conversions between types of variables involved, even in a numeric string. <br />
<br />
Local variables are initialized other than string. <br />
<br />
Local Arrays are automatically deleted from the cache after use.<br />
Operator precedence as in C + +.<br />
Checking the logical conditions faster and shorter.<br />
Qe speciales replace functions init, start and deinit <br />
<br />
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. <br />
<br />
The function init () has an analogous MQL4 mql5 the function OnInit () function start () has its analogue in OnStart () and deinit () in OnDeinit (). <br />
<br />
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:<br />
<br />
void OnInit () (<br />
init ();<br />
)<br />
OnDeinit void ()<br />
deinit ();<br />
) <br />
<br />
<br />
<br />
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. <br />
<br />
<br />
Predefined Variables MQL5 <br />
<br />
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:<br />
_Digits: Returns the decimal number dei available in the price of contización the symbol of the current graphic. <br />
<br />
Point: Pip stores the size of the symbol on the current chart.<br />
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 (). <br />
<br />
Period: Stores the current period of a graphic that is running the program.<br />
Symbol: Contains the name of the symbol of the current graphic.<br />
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.<br />
UninitReason: Contains the reason code to stop the execution of a program mql5. <br />
<br />
Variables exteranas <br />
<br />
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”. <br />
<br />
Timeseries Access <br />
<br />
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 . <br />
<br />
Expert Advisors <br />
<br />
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: <br />
<br />
OnTick: analogous to the start of MQL4 function is executed every time you get a new tick. <br />
<br />
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 ().<br />
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.<br />
OnBookEvent I have not been able to understand that it is this event, I will continue studying for acutalizar this data. <br />
<br />
OnTrade: event generated following completion of a transaction between the terminal and the server (eg submission, amendment or cancellation of an order). <br />
<br />
OnTester: Event generated when we pass the final test of an EA in eStrategy tester.<br />
You OnCalculate is only for OnStart only indicators and scripts. <br />
<br />
Custom Indicators <br />
<br />
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. <br />
<br />
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. <br />
<br />
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. <br />
<br />
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. <br />
<br />
Conclusion <br />
<br />
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.mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-55703576847915587442010-09-18T08:38:00.000-07:002010-11-16T08:50:48.120-08:00Here Comes the New MetaTrader 5 and MQL5<p>Here is MT5 in action! :</p><p><img src="http://articles.mql4.com/c/articles/2009/09/MT51.gif" height="500" width="500" /></p><p align="justify">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.</p><p>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:</p><pre class="code">SymbolInfoDouble(Symbol(),SYMBOL_BID);</pre><p align="justify">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.</p><p>Now only the necessary range can be read, which considerably saves time and memory.</p><pre class="code"> MqlRates rates_arrayG[];
Int Bar=30; // read only 30 bars stating from the zero one
iCopBar=CopyRates(Symbol(),PERIOD_M1,0,Bar,rates_arrayG);</pre><p>This feature saves both time and memory.</p><p>Such a change in functionality doesn’t frighten. We’ll simply need time to learn new functions-analogs.</p><h3>Some functional innovations that I waited from MQL:</h3><ul><li>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);</li>
<li>OnTrade() – function to process trade events – trade position opening, closing or volume change;</li>
<li> OnChartEvent() – processing events by teh mouse or keyboard.</li>
</ul><p>Let’s dwell a little on them.</p><p>The OnTimer() function is called if the timer is pre-initialized in the OnInit preset function (processor of EA initialization events).</p><p><strong>Example:</strong></p><pre class="code"><span class="hl-code"></span><span class="hl-comment">//+------------------------------------------------------------------+</span>
<span class="hl-comment">//| |</span>
<span class="hl-comment">//+------------------------------------------------------------------+</span>
<span class="hl-reserved">int</span> OnInit<span class="hl-code">(</span><span class="hl-code">)</span>
<span class="hl-code">{</span>
EventSetTimer<span class="hl-code">(</span><span class="hl-number">1</span><span class="hl-code">)</span><span class="hl-code">;</span> <span class="hl-comment">//each second we'll refer to OnTimer()</span>
<span class="hl-code">}</span>
<span class="hl-comment">//+------------------------------------------------------------------+</span>
<span class="hl-comment">//| |</span>
<span class="hl-comment">//+------------------------------------------------------------------+</span>
<span class="hl-reserved">void</span> OnDeinit<span class="hl-code">(</span><span class="hl-code">)</span>
<span class="hl-code">{</span>
EventKillTimer<span class="hl-code">(</span><span class="hl-code">)</span><span class="hl-code">;</span> <span class="hl-comment">// canceling of timer reference must be called at exit</span>
<span class="hl-code">}</span>
<span class="hl-comment">//+------------------------------------------------------------------+</span>
<span class="hl-comment">//| |</span>
<span class="hl-comment">//+------------------------------------------------------------------+</span>
<span class="hl-reserved">void</span> OnTimer<span class="hl-code">(</span><span class="hl-code">)</span>
<span class="hl-code">{</span>
MqlDateTime str1<span class="hl-code">;</span>
<span class="hl-predfunc">TimeGMT</span><span class="hl-code">(</span>str1<span class="hl-code">)</span><span class="hl-code">;</span> <span class="hl-comment">// new function to get GMT time</span>
<span class="hl-predfunc">Comment</span><span class="hl-code">(</span>str1<span class="hl-code">.</span>hour
<span class="hl-code">,</span>str1<span class="hl-code">.</span>min
<span class="hl-code">,</span>str1<span class="hl-code">.</span>sec
<span class="hl-code">,</span>str1<span class="hl-code">.</span>day
<span class="hl-code">,</span>str1<span class="hl-code">.</span>mon
<span class="hl-code">,</span>str1<span class="hl-code">.</span>year
<span class="hl-code">,</span>str1<span class="hl-code">.</span>day_of_year
<span class="hl-code">,</span><span class="hl-predfunc">OrdersTotal</span><span class="hl-code">(</span><span class="hl-code">)</span>
<span class="hl-code">,</span>PositionsTotal<span class="hl-code">(</span><span class="hl-code">)</span>
<span class="hl-code">)</span><span class="hl-code">;</span>
<span class="hl-code">}</span></pre><p>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.</p><p>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.</p><p>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.</p><p>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:</p><ul><li>CHARTEVENT_KEYDOWN — key pressing event;</li>
<li>CHARTEVENT_OBJECT_CLICK — event of a mouse click on a graphical object belonging to a chart;</li>
<li>CHARTEVENT_OBJECT_DRAG — event of a graphical object moving performed by a mouse;</li>
<li>CHARTEVENT_OBJECT_ENDEDIT — event of text editing end;</li>
<li>CHARTEVENT_CUSTOM+n — identifier of a custom event;</li>
<li>CHARTEVENT_CUSTOM_LAST — the last one.</li>
</ul><h3>The possibility to manage trading and graphics on a new functional level – this is what the developers have promised.</h3><p>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.</p><p><img src="http://articles.mql4.com/c/articles/2009/09/MT53_small.gif" height="440" width="500" /></p><p align="justify">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.</p><p>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.</p><p align="justify"><a href="http://articles.mql4.com/c/articles/2009/09/2.png" target="_blank"></a>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.</p><h3>Now there are no files for different timeframes in the HISTORY catalog</h3><p><img src="http://articles.mql4.com/c/articles/2009/09/MT54.GIF" height="141" width="449" /></p><h3>Another pleasant introduction is that now we can clear logs.</h3><p><img src="http://articles.mql4.com/c/articles/2009/09/MT52.gif" height="457" width="426" /></p><p>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 – <a href="http://forum.mql4.com/25649" target="_blank">the testing started on 2009.09.09</a>. 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.</p><p>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!</p><p align="left">Best regards,<br />
<br />
Yuriy Zaytsev</p>mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-15578798286417279912010-09-16T08:35:00.000-07:002010-11-16T08:50:14.687-08:00More Forex Profits With New MT5 Expert Advisors<p>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.</p><p>MT5 has a new integrated development environment called MQL5 which includes MetaEditor 5, MetaTrader 5 Strategy Tester and MetaQuotes Language 5 (MQL5).</p><p>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.<span id="more-954"></span><br />
<br />
<img class="aligncenter size-full wp-image-955" src="http://forexmagnates.com/wp-content/uploads/2009/06/mt5_debug_small.png" alt="mt5 debug small More Forex Profits With New MT5 Expert Advisors" width="550" height="414" title="More Forex Profits With New MT5 Expert Advisors" /></p><p>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 <em>intellisense </em>which, as most techies would agree, speeds up the development process. It also has a built-in debugger for testing.</p><p>MetaTrader 5 <strong>Strategy Tester</strong> 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 <em>“beefed-up”</em> 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.</p>mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.comtag:blogger.com,1999:blog-8562772903259219784.post-84411323988584835652010-09-11T08:10:00.000-07:002010-11-16T08:49:00.139-08:00MQL5MQL 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.<br />
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.<br />
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.<br />
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.<br />
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.<br />
Programs written down in MetaQuotes Language 5 have diverse characteristics and rationales such as: -<br />
Expert Advisor: – this is an automated trading system bonded up to an assured graphic representation.<br />
Custom Indicator: – this is a technical indicator written autonomously over and above those previously incorporated hooked on the client terminal.<br />
Script: – this is a program planned for a solitary implementation of a number of detailed deeds.<br />
Library: – this is a set of custom functions and can’t begin performing on their own.mql5http://www.blogger.com/profile/06958279930097950866noreply@blogger.com