{"id":259641,"date":"2015-06-18T19:45:02","date_gmt":"2015-06-18T15:45:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=259641"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=259641","title":{"rendered":"\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Matlab \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c"},"content":{"rendered":"<p>             \u0414\u0443\u043c\u0430\u044e, \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438\u2026 \u041b\u0443\u0447\u0448\u0435 \u043f\u043e\u044f\u0441\u043d\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e Matlab.<\/p>\n<p>  \u0412 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 MetaTrader \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043a\u0430\u043a \u0432 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u0442\u0430\u043a \u0438 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u0441 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u041a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 Nova, \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0438\u0436\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/266\/1fc\/589\/2661fc589d664272a276b92dd0a9fbe9.png\" alt=\"image\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d7d\/d9b\/0e3\/d7dd9b0e3df544f8bb6240967cc725dd.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0440\u044f\u0434\u043e\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432:<br \/>  1) \u041d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043a\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0438\u043d\u0443\u0442\u043d\u044b\u0445, 5-\u043c\u0438\u043d\u0443\u0442\u043d\u044b\u0445, 15-\u043c\u0438\u043d\u0443\u0442\u043d\u044b\u0445 \u0438 \u0442.\u0434. \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u043e\u0432;<br \/>  2) \u0414\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043a\u0443\u0434\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440;<br \/>  3) \u0427\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0439, \u043d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c;<br \/>  4) \u0421\u0430\u043c\u0430 \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f.<\/p>\n<p>  \u0410 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043a\u043e\u0432\u044b\u0435 (\u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0435\u0436\u0435\u0441\u0435\u043a\u0443\u043d\u0434\u043d\u044b\u0435) \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0430\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c\u0438 \u0438 \u0442.\u0434.<\/p>\n<p>  \u0412\u0441\u0451 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Matlab \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439. \u041e\u0442 MetaTrader \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0432 \u043c\u043e\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435: \u0435\u0436\u0435\u0441\u0435\u043a\u0443\u043d\u0434\u043d\u044b\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0446\u0435\u043d\u044b \u043f\u043e 27-\u043c\u0438 \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c). \u041f\u043e\u0442\u043e\u043c MetaTrader \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0432\u0438\u0434\u0435 DLL, \u043d\u043e \u0432\u0441\u044f \u0441\u0430\u043c\u0430\u044f \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0435.<\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c, \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430 MQL4 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>\/\/+------------------------------------------------------------------+ \/\/|                                               pack_collector.mq4 | \/\/|                                         Copyright 2014, JamaGava | \/\/|                                                                  | \/\/+------------------------------------------------------------------+ #property copyright &quot;Copyright 2014, JamaGava&quot; #property link      &quot;&quot; #property version   &quot;1.00&quot; #property strict  int filehandleData; int filehandleHead; int filehandleVolHead; int filehandleVolData;  \/\/+------------------------------------------------------------------+ \/\/| Expert initialization function                                   | \/\/+------------------------------------------------------------------+ int OnInit() {    EventSetTimer(1);    filehandleData = FileOpen(&quot;tickPack.csv&quot;,FILE_WRITE|FILE_CSV);    filehandleHead = FileOpen(&quot;tickPackHead.csv&quot;,FILE_WRITE|FILE_CSV);    filehandleVolHead = FileOpen(&quot;tickPackVolumeHead.csv&quot;,FILE_WRITE|FILE_CSV);    filehandleVolData = FileOpen(&quot;tickPackVolume.csv&quot;,FILE_WRITE|FILE_CSV);        FileWrite(filehandleHead,                    &quot;bid:AUD\/USD&quot;, &quot;ask:AUD\/USD&quot;,               &quot;bid:EUR\/USD&quot;, &quot;ask:EUR\/USD&quot;,               &quot;bid:GBP\/USD&quot;, &quot;ask:GBP\/USD&quot;,               &quot;bid:NZD\/USD&quot;, &quot;ask:NZD\/USD&quot;,               &quot;bid:USD\/CAD&quot;, &quot;ask:USD\/CAD&quot;,               &quot;bid:USD\/CHF&quot;, &quot;ask:USD\/CHF&quot;,               &quot;bid:USD\/JPY&quot;, &quot;ask:USD\/JPY&quot;,               &quot;bid:AUD\/CAD&quot;, &quot;ask:AUD\/CAD&quot;,               &quot;bid:AUD\/CHF&quot;, &quot;ask:AUD\/CHF&quot;,               &quot;bid:AUD\/NZD&quot;, &quot;ask:AUD\/NZD&quot;,               &quot;bid:CAD\/CHF&quot;, &quot;ask:CAD\/CHF&quot;,               &quot;bid:EUR\/AUD&quot;, &quot;ask:EUR\/AUD&quot;,               &quot;bid:EUR\/CAD&quot;, &quot;ask:EUR\/CAD&quot;,               &quot;bid:EUR\/CHF&quot;, &quot;ask:EUR\/CHF&quot;,               &quot;bid:EUR\/GBP&quot;, &quot;ask:EUR\/GBP&quot;,               &quot;bid:EUR\/NZD&quot;, &quot;ask:EUR\/NZD&quot;,               &quot;bid:GBP\/AUD&quot;, &quot;ask:GBP\/AUD&quot;,               &quot;bid:GBP\/CAD&quot;, &quot;ask:GBP\/CAD&quot;,               &quot;bid:GBP\/CHF&quot;, &quot;ask:GBP\/CHF&quot;,               &quot;bid:GBP\/NZD&quot;, &quot;ask:GBP\/NZD&quot;,               &quot;bid:NZD\/CAD&quot;, &quot;ask:NZD\/CAD&quot;,               &quot;bid:NZD\/CHF&quot;, &quot;ask:NZD\/CHF&quot;,               &quot;bid:AUD\/JPY&quot;, &quot;ask:AUD\/JPY&quot;,               &quot;bid:CAD\/JPY&quot;, &quot;ask:CAD\/JPY&quot;,               &quot;bid:CHF\/JPY&quot;, &quot;ask:CHF\/JPY&quot;,               &quot;bid:EUR\/JPY&quot;, &quot;ask:EUR\/JPY&quot;,               &quot;bid:GBP\/JPY&quot;, &quot;ask:GBP\/JPY&quot;,               &quot;bid:NZD\/JPY&quot;, &quot;ask:NZD\/JPY&quot;                                         );                                FileWrite(filehandleVolHead,                    &quot;volume:AUD\/USD&quot;,               &quot;volume:EUR\/USD&quot;,               &quot;volume:GBP\/USD&quot;,               &quot;volume:NZD\/USD&quot;,               &quot;volume:USD\/CAD&quot;,               &quot;volume:USD\/CHF&quot;,               &quot;volume:USD\/JPY&quot;,               &quot;volume:AUD\/CAD&quot;,               &quot;volume:AUD\/CHF&quot;,               &quot;volume:AUD\/NZD&quot;,               &quot;volume:CAD\/CHF&quot;,               &quot;volume:EUR\/AUD&quot;,               &quot;volume:EUR\/CAD&quot;,               &quot;volume:EUR\/CHF&quot;,               &quot;volume:EUR\/GBP&quot;,               &quot;volume:EUR\/NZD&quot;,               &quot;volume:GBP\/AUD&quot;,               &quot;volume:GBP\/CAD&quot;,               &quot;volume:GBP\/CHF&quot;,               &quot;volume:GBP\/NZD&quot;,               &quot;volume:NZD\/CAD&quot;,               &quot;volume:NZD\/CHF&quot;,               &quot;volume:AUD\/JPY&quot;,               &quot;volume:CAD\/JPY&quot;,               &quot;volume:CHF\/JPY&quot;,               &quot;volume:EUR\/JPY&quot;,               &quot;volume:GBP\/JPY&quot;,               &quot;volume:NZD\/JPY&quot;                                         );    FileClose(filehandleHead);    FileClose(filehandleVolHead);    return(INIT_SUCCEEDED); }    \/\/+------------------------------------------------------------------+ \/\/| Expert deinitialization function                                 | \/\/+------------------------------------------------------------------+ void OnDeinit(const int reason) {    EventKillTimer();    FileClose(filehandleData); }  \/\/+------------------------------------------------------------------+ \/\/| Timer function                                                   | \/\/+------------------------------------------------------------------+ void OnTimer() {    FileWrite(filehandleData,                MarketInfo(&quot;AUDUSD&quot;, MODE_BID), MarketInfo(&quot;AUDUSD&quot;, MODE_ASK),               MarketInfo(&quot;EURUSD&quot;, MODE_BID), MarketInfo(&quot;EURUSD&quot;, MODE_ASK),               MarketInfo(&quot;GBPUSD&quot;, MODE_BID), MarketInfo(&quot;GBPUSD&quot;, MODE_ASK),               MarketInfo(&quot;NZDUSD&quot;, MODE_BID), MarketInfo(&quot;NZDUSD&quot;, MODE_ASK),               MarketInfo(&quot;USDCAD&quot;, MODE_BID), MarketInfo(&quot;USDCAD&quot;, MODE_ASK),               MarketInfo(&quot;USDCHF&quot;, MODE_BID), MarketInfo(&quot;USDCHF&quot;, MODE_ASK),               MarketInfo(&quot;USDJPY&quot;, MODE_BID), MarketInfo(&quot;USDJPY&quot;, MODE_ASK),               MarketInfo(&quot;AUDCAD&quot;, MODE_BID), MarketInfo(&quot;AUDCAD&quot;, MODE_ASK),               MarketInfo(&quot;AUDCHF&quot;, MODE_BID), MarketInfo(&quot;AUDCHF&quot;, MODE_ASK),                MarketInfo(&quot;AUDNZD&quot;, MODE_BID), MarketInfo(&quot;AUDNZD&quot;, MODE_ASK),               MarketInfo(&quot;CADCHF&quot;, MODE_BID), MarketInfo(&quot;CADCHF&quot;, MODE_ASK),               MarketInfo(&quot;EURAUD&quot;, MODE_BID), MarketInfo(&quot;EURAUD&quot;, MODE_ASK),               MarketInfo(&quot;EURCAD&quot;, MODE_BID), MarketInfo(&quot;EURCAD&quot;, MODE_ASK),               MarketInfo(&quot;EURCHF&quot;, MODE_BID), MarketInfo(&quot;EURCHF&quot;, MODE_ASK),               MarketInfo(&quot;EURGBP&quot;, MODE_BID), MarketInfo(&quot;EURGBP&quot;, MODE_ASK),               MarketInfo(&quot;EURNZD&quot;, MODE_BID), MarketInfo(&quot;EURNZD&quot;, MODE_ASK),               MarketInfo(&quot;GBPAUD&quot;, MODE_BID), MarketInfo(&quot;GBPAUD&quot;, MODE_ASK),               MarketInfo(&quot;GBPCAD&quot;, MODE_BID), MarketInfo(&quot;GBPCAD&quot;, MODE_ASK),               MarketInfo(&quot;GBPCHF&quot;, MODE_BID), MarketInfo(&quot;GBPCHF&quot;, MODE_ASK),               MarketInfo(&quot;GBPNZD&quot;, MODE_BID), MarketInfo(&quot;GBPNZD&quot;, MODE_ASK),               MarketInfo(&quot;NZDCAD&quot;, MODE_BID), MarketInfo(&quot;NZDCAD&quot;, MODE_ASK),               MarketInfo(&quot;NZDCHF&quot;, MODE_BID), MarketInfo(&quot;NZDCHF&quot;, MODE_ASK),               MarketInfo(&quot;AUDJPY&quot;, MODE_BID), MarketInfo(&quot;AUDJPY&quot;, MODE_ASK),               MarketInfo(&quot;CADJPY&quot;, MODE_BID), MarketInfo(&quot;CADJPY&quot;, MODE_ASK),               MarketInfo(&quot;CHFJPY&quot;, MODE_BID), MarketInfo(&quot;CHFJPY&quot;, MODE_ASK),               MarketInfo(&quot;EURJPY&quot;, MODE_BID), MarketInfo(&quot;EURJPY&quot;, MODE_ASK),               MarketInfo(&quot;GBPJPY&quot;, MODE_BID), MarketInfo(&quot;GBPJPY&quot;, MODE_ASK),               MarketInfo(&quot;NZDJPY&quot;, MODE_BID), MarketInfo(&quot;NZDJPY&quot;, MODE_ASK)            );                FileWrite(filehandleVolData,                iVolume(&quot;AUDUSD&quot;, PERIOD_H1,0),               iVolume(&quot;EURUSD&quot;, PERIOD_H1,0),               iVolume(&quot;GBPUSD&quot;, PERIOD_H1,0),               iVolume(&quot;NZDUSD&quot;, PERIOD_H1,0),               iVolume(&quot;USDCAD&quot;, PERIOD_H1,0),               iVolume(&quot;USDCHF&quot;, PERIOD_H1,0),               iVolume(&quot;USDJPY&quot;, PERIOD_H1,0),               iVolume(&quot;AUDCAD&quot;, PERIOD_H1,0),               iVolume(&quot;AUDCHF&quot;, PERIOD_H1,0),                iVolume(&quot;AUDNZD&quot;, PERIOD_H1,0),               iVolume(&quot;CADCHF&quot;, PERIOD_H1,0),               iVolume(&quot;EURAUD&quot;, PERIOD_H1,0),               iVolume(&quot;EURCAD&quot;, PERIOD_H1,0),               iVolume(&quot;EURCHF&quot;, PERIOD_H1,0),               iVolume(&quot;EURGBP&quot;, PERIOD_H1,0),               iVolume(&quot;EURNZD&quot;, PERIOD_H1,0),               iVolume(&quot;GBPAUD&quot;, PERIOD_H1,0),               iVolume(&quot;GBPCAD&quot;, PERIOD_H1,0),               iVolume(&quot;GBPCHF&quot;, PERIOD_H1,0),               iVolume(&quot;GBPNZD&quot;, PERIOD_H1,0),               iVolume(&quot;NZDCAD&quot;, PERIOD_H1,0),               iVolume(&quot;NZDCHF&quot;, PERIOD_H1,0),               iVolume(&quot;AUDJPY&quot;, PERIOD_H1,0),               iVolume(&quot;CADJPY&quot;, PERIOD_H1,0),               iVolume(&quot;CHFJPY&quot;, PERIOD_H1,0),               iVolume(&quot;EURJPY&quot;, PERIOD_H1,0),               iVolume(&quot;GBPJPY&quot;, PERIOD_H1,0),               iVolume(&quot;NZDJPY&quot;, PERIOD_H1,0)            );   } \/\/+------------------------------------------------------------------+ <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 CSV. \u0412 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445: \u0432\u0435\u0441\u044c \u0440\u044f\u0434 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043e\u043a bid \u0438 ask \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0439 \u043f\u0430\u0440\u044b. \u0418\u0442\u043e\u0433\u043e, \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 2 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0445 \u043f\u0430\u0440.<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c MetaTrader \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e, \u0442\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0430\u043c\u0438: \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438, \u0437\u0430\u043a\u0440\u044b\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b\u0438 \u0444\u0430\u0439\u043b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0442\u0451\u0440\u0441\u044f, \u043c\u043e\u0436\u0435\u043c \u0432\u043d\u043e\u0432\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u0442.\u0434.<\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0443 \u043c\u0435\u043d\u044f \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 16 \u043d\u0435\u0434\u0435\u043b\u044c. \u041f\u0440\u0438\u0447\u0451\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u0431\u043e\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u00ab\u0433\u0434\u0435-\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u0434\u043d\u044f\u00bb \u0432 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a\u0430, \u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u043b\u0441\u044f \u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u00ab\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0435\u0434\u0430\u00bb. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u0431\u043b\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430. \u0412 Matlab \u044f \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 loadPrices.m:<\/p>\n<pre><code class=\"matlab\">global PRICES; N = 16;  PRICES = cell( N, 1 );  fNames = {         'C:\\matlabR2008a_win\\work\\frx\\DATA\\1\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\2\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\3\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\4\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\5\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\6\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\7\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\8\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\9\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\10\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\11\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\12\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\13\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\14\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\15\\tickPack.csv';         'C:\\matlabR2008a_win\\work\\frx\\DATA\\16\\tickPack.csv';     };   for i = 1:N     PRICES{ i } = load( fNames{ i } );     display( i ); end  <\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u0441\u0435 \u0431\u043b\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 PRICES, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u0441\u043e\u0431\u043e\u0439 16 \u044f\u0447\u0435\u0435\u043a. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u043d\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u0412\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0412 \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u0434\u0435\u043b\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u00ab\u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443\u00bb, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0438, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 testStrat.m:<\/p>\n<pre><code class=\"matlab\">function [R] = testStrat( P )  global DrawDown; global Recovery; global Equity; global DealsNumber; global MeanDeal; global DealsSigma; global Sharp; global ProfitFactor; global ProfitDealsNumber; global ProfitDealsRate; global ProfitMean; global LossDealsNumber; global LossDealsRate; global LossMean;  global returnParamIndex;  global stratName;   initRates( 0 );   feval( stratName, P );   switch( returnParamIndex )     case 1         R = DrawDown;              case 2         R = -Recovery;              case 3         R = -Equity;              case 4         R = -DealsNumber;              case 5         R = -MeanDeal;              case 6         R = DealsSigma;              case 7         R = -Sharp;              case 8         R = -ProfitFactor;              case 9         R = -ProfitDealsNumber;              case 10         R = -ProfitDealsRate;              case 11         R = -ProfitMean;              case 12         R = LossDealsNumber;              case 13         R = LossDealsRate;              case 14         R = LossMean;              case 0         R = struct(                                              ...                 'DrawDown',              DrawDown,               ...                 'Recovery',              Recovery,               ...                 'Equity',                Equity,                 ...                 'DealsNumber',           DealsNumber,            ...                 'MeanDeal',              MeanDeal,               ...                 'DealsSigma',            DealsSigma,             ...                 'Sharp',                 Sharp,                  ...                 'ProfitFactor',          ProfitFactor,           ...                 'ProfitDealsNumber',     ProfitDealsNumber,      ...                 'ProfitDealsRate',       ProfitDealsRate,        ...                 'ProfitMean',            ProfitMean,             ...                 'LossDealsNumber',       LossDealsNumber,        ...                 'LossDealsRate',         LossDealsRate,          ...                 'LossMean',              LossMean                ...             );          end  <\/code><\/pre>\n<p>  \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e stratName. \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 returnParamIndex, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u00ab\u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435\u00bb \u0441\u0442\u043e\u044f\u0442 \u0441 \u043c\u0438\u043d\u0443\u0441\u043e\u043c, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438: \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<br \/>  DrawDown \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0441\u0430\u0434\u043a\u0430 (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u043e\u043c \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c); <br \/>  Recovery \u2014 \u0444\u0430\u043a\u0442\u043e\u0440 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f (\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0430 \u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0430\u0434\u043a\u0435);<br \/>  Equity \u2014 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448;<br \/>  DealsNumber \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0434\u0435\u043b\u043e\u043a;<br \/>  MeanDeal \u2014 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u0445\u043e\u0434 \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0435;<br \/>  DealsSigma \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u0434\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0434\u0435\u043b\u043a\u0435 \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f;<br \/>  Sharp \u2014 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0428\u0430\u0440\u043f\u0430 (\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0434\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0435 \u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044e \u0434\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0430\u043c \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f);<br \/>  ProfitFactor \u2014 \u043f\u0440\u043e\u0444\u0438\u0442 \u0444\u0430\u043a\u0442\u043e\u0440 (\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0439 \u043f\u0440\u0438\u0431\u044b\u043b\u0438 \u043a \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u043c\u0443 \u0443\u0431\u044b\u0442\u043a\u0443);<br \/>  ProfitDealsNumber \u2014 \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u043d\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a;<br \/>  ProfitDealsRate \u2014 \u0434\u043e\u043b\u044f \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u043d\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a;<br \/>  ProfitMean \u2014 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 (\u0437\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u0443\u044e \u0441\u0434\u0435\u043b\u043a\u0443);<br \/>  LossDealsNumber \u2014 \u0447\u0438\u0441\u043b\u043e \u0443\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a;<br \/>  LossDealsRate \u2014 \u0434\u043e\u043b\u044f \u0443\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a;<br \/>  LossMean \u2014 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0448 (\u0437\u0430 \u0443\u0431\u044b\u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0434\u0435\u043b\u043a\u0443).<\/p>\n<p>  \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 initRates.m<\/p>\n<pre><code class=\"matlab\">function [z] = initRates( mode )  global DrawDown; global Recovery; global Equity; global DealsNumber; global MeanDeal; global DealsSigma; global Sharp; global ProfitFactor; global ProfitDealsNumber; global ProfitDealsRate; global ProfitMean; global LossDealsNumber; global LossDealsRate; global LossMean;  global maxEquity; global dealSqr; global totalProfit; global totalLoss;  z = mode;  maxEquity   = 0; dealSqr     = 0; totalProfit = 0; totalLoss   = 0;   if mode == 0          DrawDown              = 0;     Recovery              = 0;     Equity                = 0;     DealsNumber           = 0;     MeanDeal              = 0;     DealsSigma            = 0;     Sharp                 = 0;     ProfitFactor          = 0;     ProfitDealsNumber     = 0;     ProfitDealsRate       = 0;     ProfitMean            = 0;     LossDealsNumber       = 0;     LossDealsRate         = 0;     LossMean              = 0;      else          DrawDown              =  1000;     Recovery              = -1000;     Equity                = -1000;     DealsNumber           =  0;     MeanDeal              = -1000;     DealsSigma            =  1000;     Sharp                 = -1000;     ProfitFactor          =  0;     ProfitDealsNumber     =  0;     ProfitDealsRate       =  0;     ProfitMean            =  0;     LossDealsNumber       =  100000;     LossDealsRate         =  1000;     LossMean              =  1000;      end  <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0447\u0451\u043c, \u043c\u043e\u0433\u0443\u0442 \u0438\u043d\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a 0, \u0442\u0430\u043a \u0438 \u0437\u0430\u0432\u0435\u0434\u043e\u043c\u043e \u043f\u043b\u043e\u0445\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c). \u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u0430 \u043f\u043b\u043e\u0445\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u043f\u0440\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<p>  <i>maxEquity, dealSqr, totalProfit, totalLoss,<\/i><\/p>\n<p>  \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435.<\/p>\n<p>  \u0412 \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u0434\u0435\u043b\u043a\u0438, \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e updateStratRates.m:<\/p>\n<pre><code class=\"matlab\">function [z] = updateStratRates( dealResult )  z = sign( dealResult );  global DrawDown; global Recovery; global Equity; global DealsNumber; global MeanDeal; global DealsSigma; global Sharp; global ProfitFactor; global ProfitDealsNumber; global ProfitDealsRate; global ProfitMean; global LossDealsNumber; global LossDealsRate; global LossMean;   global maxEquity; global dealSqr; global totalProfit; global totalLoss;    Equity = Equity + dealResult;  if Equity &gt; maxEquity     maxEquity = Equity; end  down = maxEquity - Equity; if down &gt; DrawDown     DrawDown = down; end  Recovery = Equity \/ DrawDown;   DealsNumber = DealsNumber + 1; MeanDeal    = Equity \/ DealsNumber; dealSqr     = dealSqr + dealResult^2; DealsSigma  = sqrt( (dealSqr \/ DealsNumber) - MeanDeal^2 ); Sharp       = MeanDeal \/ DealsSigma;  if dealResult &gt; 0     ProfitDealsNumber = ProfitDealsNumber + 1;     totalProfit       = totalProfit + dealResult;     ProfitMean        = totalProfit \/ ProfitDealsNumber; else     LossDealsNumber = LossDealsNumber + 1;     totalLoss       = totalLoss + dealResult;     LossMean        = totalLoss \/ LossDealsNumber; end  ProfitFactor    = -totalProfit \/ totalLoss; ProfitDealsRate = ProfitDealsNumber \/ DealsNumber; LossDealsRate   = 1 - ProfitDealsRate;  <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u043e\u0442 \u0438 \u0432\u0441\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 initRates \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0438 updateStratRates \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0441\u0434\u0435\u043b\u043a\u0438.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"matlab\">global pairIndex;        % \u043d\u043e\u043c\u0435\u0440\/\u043d\u043e\u043c\u0435\u0440\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0439 \u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0439 \u043f\u0430\u0440\u044b\/\u043f\u0430\u0440 global DATA;             % \u0431\u043b\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 global dataBlocksNumber; % \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 16) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, twoEMA, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  \u0418\u0434\u0435\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445. \u0412\u0445\u043e\u0434 \u0432 \u0440\u044b\u043d\u043e\u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439:<\/p>\n<p>  \u041f\u043e\u043a\u0443\u043f\u043a\u0430\/\u043f\u0440\u043e\u0434\u0430\u0436\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f:<br \/>  1) \u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0432\u044b\u0448\u0435\/\u043d\u0438\u0436\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e 4-\u0445 \u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432;<br \/>  2) \u0426\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430 \u0432\u044b\u0448\u0435\/\u043d\u0438\u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439;<br \/>  3) \u041d\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a.<\/p>\n<p>  \u0417\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439:<br \/>  1) \u0414\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u0438 \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0435;<br \/>  2) \u0414\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0431\u044b\u0442\u043a\u0430 \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0435 (tralling stop-loss \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u043e\u0441\u0442\u0430 \u0434\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0435 \u043e\u043d \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0446\u0435\u043d\u0435, \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u0443\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439);<br \/>  3) \u041f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 1 \u0438 2 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0434\u0435\u043b\u043a\u0438 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/p>\n<p>  \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0441\u0434\u0435\u043b\u043a\u0438 \u044d\u0442\u043e: \u0434\u043b\u0438\u043d\u0430 \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f 0.0001, \u00ab\u0437\u0430\u0437\u043e\u0440\u00bb \u043c\u0435\u0436\u0434\u0443 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u043c\u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0434\u0435\u043b\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0431\u044b\u043b\u0438 \u0438 \u0443\u0431\u044b\u0442\u043a\u0430 \u0432 \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u0430\u0445.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438: \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439. <br \/>  \u0412 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e, \u0432\u0435\u0434\u0451\u0442\u0441\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a, \u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0435, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0431\u044b\u0442\u043e\u043a \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0435 \u0430 \u0442\u0430\u043a \u0436\u0435 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0434\u043e\u0445\u043e\u0434\/\u043f\u043e\u0442\u0435\u0440\u0438 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0434\u0435\u043b\u043a\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0434\u0435\u043b\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u00ab\u0431\u0430\u0440\u043e\u043c\u00bb \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0430 Equity. \u041f\u0440\u0438\u0431\u044b\u043b\u044c \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0432 4-\u0445 \u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u0430\u0445.<\/p>\n<p>  twoEMA.m:<\/p>\n<pre><code class=\"matlab\">function [Z] = twoEma( P )  %{ +---------------------------------------------------------------+ !                                                               ! !  Parameters:                                                  !                                        !    timeframe = P(1)                                           ! !    E1 - slow EMA with alpha = P(2)                            ! !    E2 - fast EMA with alpha = P(3)                            ! !                                                               ! !  Open:                                                        ! !    long deal:  (openPrice &gt;= E2 &gt; E1) & abs(E1 - E2) &gt;= P(4)  ! !    short deal: (openPrice &lt;= E2 &lt; E1) & abs(E1 - E2) &gt;= P(4)  ! !                                                               ! !  Close:                                                       ! !    by trailing Stop-loss or by Take profit                    ! !                                                               ! +---------------------------------------------------------------+ %}  global pairIndex;  global DATA; global dataBlocksNumber;  global WithPlot;     % \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0438\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c global EQ;           % \u0431\u0430\u0440\u044b Equity global eqCounter;    % \u0447\u0438\u0441\u043b\u043e \u0431\u0430\u0440\u043e\u0432   % \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c if or( P( 1 ) &lt; 0,                                                           ...       or( P( 4 ) * 0.0001 &lt;= 0,                                               ...        or( P( 5 ) * 0.0001 &lt;= 0,                                             ...          or( P( 6 ) * 0.0001 &lt;= 0,                                           ...             or(                                                               ...              or( P( 2 ) * 0.0001 &lt;= 0,               P( 2 ) * 0.0001 &gt;= 1 ), ...              or( P( 3 ) * 0.0001 &lt;= P( 2 ) * 0.0001, P( 3 ) * 0.0001 &gt;= 1 )  ...            )                                                                 ...          )                                                                   ...        )                                                                     ...      )                                                                       ...    )      initRates( 1 ); % \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b, \u0442\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438                         % \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0432\u0435\u0434\u043e\u043c\u043e \u043f\u043b\u043e\u0445\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438          Z = 1;     return;      end   initRates( 0 );    % \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438       % \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0431\u0430\u0440\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0438 currEQopen    = 0; currEQmin     = 0; currEQmax     = 0; currEQclose   = 0;  TF = round( P( 1 ) ); % \u0434\u043b\u0438\u043d\u0430 \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430  for currBlock = 1:dataBlocksNumber                   currData = DATA{ currBlock };     dataSize = size( currData );     dataLen  = dataSize( 1 );     tfNumb   = ceil( dataLen \/ TF );              % \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 bid \u0438 ask \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445     bidPrices = currData( :, 2 * ( pairIndex - 1) + 1 );       askPrices = currData( :, 2 * pairIndex );              % \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     dealDir       = 0;     openDealPrice = 0;     stopLoss      = 0;     takeProfit    = 0;     currDeal      = 0;     signal        = 0;                E1 = bidPrices( 1 );     E2 = bidPrices( 1 );          currTime = 1;          for t = 2:tfNumb % \u043f\u043e \u0432\u0441\u0435\u043c \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430\u043c...                  currTime = currTime + TF;                      % \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430 (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c             % \u043a\u043e\u0440\u043e\u0447\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445)         barLen = TF;          if t == tfNumb             barLen = dataLen - TF * ( tfNumb - 1 );         end                  for tick = 2:(barLen - 1) % \u043f\u043e \u0432\u0441\u0435\u043c \u0442\u0438\u043a\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430...                                       if dealDir == 1 % \u0435\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0441\u0434\u0435\u043b\u043a\u0430 \u043f\u043e\u043a\u0443\u043f\u043a\u0438                                      % \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u043a\u0438                 currDeal = bidPrices( currTime + tick ) - openDealPrice;                                  currEQmin     = min( currDeal, currEQmin );                 currEQmax     = max( currDeal, currEQmax );                 currEQclose   = currDeal;                                      % \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u0442\u043e\u043f-\u043b\u043e\u0441\u0441                 stopLoss = max( stopLoss, bidPrices( currTime + tick ) - P( 5 ) * 0.0001 );                                       % \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u043e \u0441\u0442\u043e\u043f-\u043b\u043e\u0441\u0441\u0443 \u0438\u043b\u0438 \u0442\u0435\u0439\u043a-\u043f\u0440\u043e\u0444\u0438\u0442\u0443                 if or( bidPrices( currTime + tick ) &lt;= stopLoss,    ...                        bidPrices( currTime + tick ) &gt;= takeProfit   ...                      )                                         dealDir = 0;                                              % \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438                    updateStratRates( currDeal );                          % \u0435\u0441\u043b\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0431\u0430\u0440\u0430                         % \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0438                    if WithPlot                        [EQ, eqCounter] = updateSeries( EQ, eqCounter, [currEQopen, currEQmax, currEQmin, currEQclose] );                    end                                     end                              end              if dealDir == -1  % \u0435\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0441\u0434\u0435\u043b\u043a\u0430 \u043f\u0440\u043e\u0434\u0430\u0436\u0438                                  currDeal = openDealPrice - askPrices( currTime + tick );                                  currEQmin     = min( currDeal, currEQmin );                 currEQmax     = max( currDeal, currEQmin );                 currEQclose   = currDeal;                                      % \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u0442\u043e\u043f-\u043b\u043e\u0441\u0441                 stopLoss = min( stopLoss, askPrices( currTime + tick ) + P( 5 ) * 0.0001 );                                      % \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u043e \u0441\u0442\u043e\u043f-\u043b\u043e\u0441\u0441\u0443 \u0438\u043b\u0438 \u0442\u0435\u0439\u043a-\u043f\u0440\u043e\u0444\u0438\u0442\u0443                 if or( askPrices( currTime + tick ) &gt;= stopLoss,    ...                        askPrices( currTime + tick ) &lt;= takeProfit   ...                      )                                         dealDir = 0;                                     % \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438                    updateStratRates( currDeal );                          % \u0435\u0441\u043b\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0431\u0430\u0440\u0430                         % \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0438                    if WithPlot                        [EQ, eqCounter] = updateSeries( EQ, eqCounter, [currEQopen, currEQmax, currEQmin, currEQclose] );                    end                                      end                              end                      end                      % \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0444\u0440\u0435\u0439\u043c\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0435         E1 = E1 + P( 2 ) * 0.0001 * ( bidPrices( currTime ) - E1 );         E2 = E2 + P( 3 ) * 0.0001 * ( bidPrices( currTime ) - E2 );                      % \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0434\u0435\u043b\u043a\u0438         signal = 0;         if and( and( bidPrices( currTime ) &gt;= E2, E2 &gt; E1 ), abs( E1 - E2 ) &gt;= P( 4 ) * 0.0001 )             signal = 1;         end         if and( and( bidPrices( currTime ) &lt;= E2, E2 &lt; E1 ), abs( E1 - E2 ) &gt;= P( 4 ) * 0.0001 )             signal = -1;         end                       % \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0441\u0434\u0435\u043b\u043a\u0430 \u0438 \u0435\u0441\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435              % \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0439         if or(                                  ...             and( dealDir ==  1, signal == -1 ), ...             and( dealDir == -1, signal ==  1 )  ...             )                                                        dealDir = 0;                              % \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438            updateStratRates( currDeal );                              % \u0435\u0441\u043b\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0431\u0430\u0440\u0430                  % \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0438            if WithPlot                [EQ, eqCounter] = updateSeries( EQ, eqCounter, [currEQopen, currEQmax, currEQmin, currEQclose] );            end                 end                      % \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0434\u0435\u043b\u043a\u0438 \u043d\u0430 \u043f\u043e\u043a\u0443\u043f\u043a\u0443         if and( dealDir == 0, signal == 1 )                          dealDir = 1;             openDealPrice = askPrices( currTime ); % \u0446\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f                              % \u0441\u0442\u043e\u043f-\u043b\u043e\u0441\u0441 \u0438 \u0442\u044d\u0439\u043a-\u043f\u0440\u043e\u0444\u0438\u0442             stopLoss   = bidPrices( currTime + tick ) - P( 5 ) * 0.0001;              takeProfit = bidPrices( currTime + tick ) + P( 6 ) * 0.0001;                              % \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0431\u0430\u0440\u0430 Equity             currEQopen    = askPrices( currTime + tick ) - bidPrices( currTime + tick );             currEQmin     = askPrices( currTime + tick ) - bidPrices( currTime + tick );             currEQmax     = askPrices( currTime + tick ) - bidPrices( currTime + tick );             currEQclose   = askPrices( currTime + tick ) - bidPrices( currTime + tick );                      end                      % \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0434\u0435\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0434\u0430\u0436\u0443         if and( dealDir == 0, signal == -1 )                          dealDir = -1;             openDealPrice = bidPrices( currTime ); % \u0446\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f                              % \u0441\u0442\u043e\u043f-\u043b\u043e\u0441\u0441 \u0438 \u0442\u044d\u0439\u043a-\u043f\u0440\u043e\u0444\u0438\u0442             stopLoss   = askPrices( currTime + tick ) + P( 5 ) * 0.0001;             takeProfit = askPrices( currTime + tick ) - P( 6 ) * 0.0001;                              % \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0431\u0430\u0440\u0430 Equity             currEQopen    = askPrices( currTime + tick ) - bidPrices( currTime + tick );             currEQmin     = askPrices( currTime + tick ) - bidPrices( currTime + tick );             currEQmax     = askPrices( currTime + tick ) - bidPrices( currTime + tick );             currEQclose   = askPrices( currTime + tick ) - bidPrices( currTime + tick );                      end              end              % \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u0434\u0435\u043b\u043a\u0438     if dealDir ~= 0                      % \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438         updateStratRates( currDeal );              % \u0435\u0441\u043b\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0431\u0430\u0440\u0430             % \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0434\u0435\u043b\u043a\u0438         if WithPlot             [EQ, eqCounter] = updateSeries( EQ, eqCounter, [currEQopen, currEQmax, currEQmin, currEQclose] );         end              end      end   Z = 0;  <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f updateSeries, \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u00abpush_back\u00bb.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f updateSeries.m:<\/p>\n<pre><code class=\"matlab\">function [S, I] = updateSeries(s, i, v)  if i == 0          S = v;     I = 1;      else          I = i + 1;     S = [s; v];           end  <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 mainScript.m:<\/p>\n<pre><code class=\"matlab\">% loadPrices;            % \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445  global stratName; global returnParamIndex;  global pairIndex; global DATA; global PRICES; global dataBlocksNumber;  global WithPlot; global EQ; global eqCounter;   stratName        = 'twoEma'; % \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c twoEMA  pairIndex = 2;               % \u0432\u0442\u043e\u0440\u0430\u044f \u0432\u0430\u043b\u044e\u0442\u043d\u0430\u044f \u043f\u0430\u0440\u0430 (EUR\/USD)   DATA      = PRICES;  dataBlocksNumber = 16;  WithPlot = false;           % \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438   P = [900, 100, 310, 25, 100, 40]; % \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  returnParamIndex = 7;             % \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0428\u0430\u0440\u043f\u0430  P = fminsearch( 'testStrat', P ); display(P);   WithPlot = true;                % \u0440\u0435\u0436\u0438\u043c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 EQ = 0; eqCounter = 0; returnParamIndex = 0; R = testStrat( P );  display(R);  for i = 2:eqCounter   % \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0431\u0430\u0440\u044b \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0430\u043c \u043a \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443          EQ( i, 1 ) = EQ( i, 1 ) + EQ( i - 1, 4 );     EQ( i, 2 ) = EQ( i, 2 ) + EQ( i - 1, 4 );     EQ( i, 3 ) = EQ( i, 3 ) + EQ( i - 1, 4 );     EQ( i, 4 ) = EQ( i, 4 ) + EQ( i - 1, 4 );      end  candle(EQ(:, 2), EQ(:, 3), EQ(:, 4), EQ(:, 1)); title('Equity'); <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 equity \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/694\/89b\/154\/69489b1546e64b59b12f6a211c9c0636.png\" alt=\"image\"\/><\/p>\n<p>  \u0410 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0442\u0430\u043a:<\/p>\n<p>  DrawDown: 0.0105<br \/>  Recovery: 12.6103<br \/>  Equity: 0.1320<br \/>  DealsNumber: 47<br \/>  MeanDeal: 0.0028<br \/>  DealsSigma: 0.0056<br \/>  Sharp: 0.5034<br \/>  ProfitFactor: 3.3393<br \/>  ProfitDealsNumber: 34<br \/>  ProfitDealsRate: 0.7234<br \/>   ProfitMean: 0.0055<br \/>  LossDealsNumber: 13<br \/>  LossDealsRate: 0.2766<br \/>  LossMean: -0.0043<\/p>\n<p>  \u041c\u043e\u0433\u043b\u043e \u0431\u044b\u0442\u044c \u0438 \u043b\u0443\u0447\u0448\u0435\u2026 \u0427\u0442\u043e \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0443\u043c\u0430 \u0447\u0435\u043c fminsearch, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0433\u043b\u0430\u0434\u043a\u043e\u0439, \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0438 \u0443\u043d\u043e\u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0439\u2026<\/p>\n<p>  \u041d\u043e \u0432\u0435\u0434\u044c \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0410 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Matlab \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b.             <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/260635\/\"> http:\/\/habrahabr.ru\/post\/260635\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>             \u0414\u0443\u043c\u0430\u044e, \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438\u2026 \u041b\u0443\u0447\u0448\u0435 \u043f\u043e\u044f\u0441\u043d\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e Matlab.<\/p>\n<p>  \u0412 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 MetaTrader \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043a\u0430\u043a \u0432 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u0442\u0430\u043a \u0438 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u0441 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u041a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 Nova, \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0438\u0436\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-259641","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/259641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=259641"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/259641\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=259641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=259641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=259641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}