Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2016.03.25 14:10
Auto optimizer

Auto optimizer - library for MetaTrader 4

| English Español Русский 中文 Deutsch 日本語 Português

Views:
1086
Rating:
votes: 6
\MQL4\Include\

The detailed article on the usage of the auto optimizer library and principles of its operation can be found here: https://www.mql5.com/en/articles/1467

The code to insert in your EA:

//----
extern int SetHour   = 0;                 //Optimization starting hour 
extern int SetMinute = 1;                 //Optimization starting minute 
int    TestDay       = 3;                 //Number of days for optimization
int    TimeOut       = 4;                 //Optimization end timeout in minutes
string NameMTS       = "Expert_Name";     //EA's name
string NameFileSet   = "SetFileName.set"; //Name of the Set-file with the settings
string PuthTester    = "PathTester";      //Path to the tester
//--- Filtering order
int    Gross_Profit   = 1;                //Sorting by Maximal profit
int    Profit_Factor  = 2;                //Sorting by Maximal profit factor
int    Expected_Payoff= 3;                //Sorting by Maximal expected payoff
//--variable names for optimization
string Per1 = "variables_1";
string Per2 = "variables_2";
string Per3 = "variables_3";
string Per4 = "variables_4";
bool StartTest=false;
datetime TimeStart;
//--- Include the auto optimizer library
#include <auto_optimization.mqh>
 
//----
The code to insert in the start() function
//----
// Not to be launched at testing and optimizing   
if(!IsTesting() && !IsOptimization())
  {
    // Compare the current hour with that preset for launching
    if(TimeHour(TimeLocal()) == SetHour)
      {
        // Protection against restarting
        if(!StartTest)
          {
            // Compare the minute range to the minute preset for launching
            if(TimeMinute(TimeLocal()) > SetMinute - 1)
              { 
                // the range is necessary, if for some reason 
                // no new tick is available for a long time
                if(TimeMinute(TimeLocal()) < SetMinute + 1)
                  {
                    TimeStart = TimeLocal();
                    StartTest = true;   // Flag of tester launching
                    Tester(TestDay, NameMTS, NameFileSet, PuthTester, TimeOut, 
                           Gross_Profit, Profit_Factor, Expected_Payoff, Per1, 
                           Per2, Per3, Per4);
                  }
              }
          }
      }
    variables_1 = GlobalVariableGet(Per1);
    variables_2 = GlobalVariableGet(Per2);
    variables_3 = GlobalVariableGet(Per3);
    variables_4 = GlobalVariableGet(Per4);
  }
// If the tester launching is flagged
if(StartTest)
  {
    // If more time has elapsed the launching than it was set 
    // to be the test waiting time
    if(TimeLocal() - TimeStart  > TimeOut*60)
      {
        StartTest = false;  // Zero the flag
      }
  }
//----
Added the auto optimizer library modified for the 204 Build -а  auto_optimization_204.mqh 
Accordingly, the code for calling the library will be as follows
//--- Include the auto optimizer library
#include <auto_optimization_204.mqh>

Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/7090

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

LinesProfitLoss LinesProfitLoss

Calculates profit (loss) of the current orders on the symbol.

FFC - Forex Factory Calendar FFC - Forex Factory Calendar

Modified version of FF Calendar Indicator with new features.