Libraries: MultiTester - page 16

 

The most convenient way to download the history of ticks (run the Expert Advisor in the Terminal).

#property description "Downloads ticks through Tester."

sinput datetime inFromDate = D'2019.01.01'; // From which date to upload ticks
sinput bool inAllSymbols = false;           // By all characters (true) or the current character (false)

#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/ru/code/26132

string PrevTesterSettings = NULL;

string GetMyName( void )
{
  return(StringSubstr(MQLInfoString(MQL_PROGRAM_PATH), StringLen(TerminalInfoString(TERMINAL_DATA_PATH) + "\\MQL5\\Experts\\")));
}

bool RunMe( const datetime FromDate, const bool AllSymbols = false )
{
  const string Str = "[Tester]" +
                     "\nExpert=" + GetMyName() +
                     "\nSymbol=" + _Symbol +
                     "\nOptimization=" + (AllSymbols ? "3" : "0") +
                     "\nModel=4" +
                     "\nFromDate=" + TimeToString(FromDate, TIME_DATE) +
                     "\nToDate=" + TimeToString(TimeCurrent(), TIME_DATE) +
                     "\nForwardMode=0" +
                     "\nProfitInPips=1" +
                     "\nOptimizationCriterion=0" +
                     "\nVisual=0";
                     
  return(MTTESTER::SetSettings2(Str) && MTTESTER::ClickStart());
}

int OnInit()
{
  bool Res = !MQLInfoInteger(MQL_TESTER) && EventSetTimer(1);

  if (Res = Res && MTTESTER::GetSettings(PrevTesterSettings))
    if (!(Res = RunMe(inFromDate, inAllSymbols)))
      MTTESTER::SetSettings2(PrevTesterSettings);

  return(Res ? INIT_SUCCEEDED : INIT_FAILED);
}

void OnTimer()
{
  if (MTTESTER::IsReady())
  {
    MTTESTER::SetSettings2(PrevTesterSettings);
    
    if (inAllSymbols)
      MTTESTER::CloseNotChart();

    ExpertRemove();
  }
}


After that, you can run scripts that work with ticks in the Terminal and not wait a lot of time without signs of life.

 
Stanislav Korotky:

You can get rid of the need to write your own MQL5 controller for TesterSettings.Add calls by supporting the text format of tester pass settings (like symbols, timeframes and other things that can be passed to TesterSettings.Add in each line). Then make a universal Expert Advisor-controller (add to the library), which takes as input a single parameter - a file with settings and implements SetTesterSettings on its basis, then the user does not need to program anything.

In the end, I did this. We form a batch of tasks from ini-files and send it for execution.

But often there are tasks when it is necessary to form a task on the basis of the results of previous ones. Therefore, the ini variant is not always suitable.


ZY The implementation is here.

 
For those practicing automation of the Tester, I recommend looking at the following settings
MQL5\Profiles\Tester\Groups\*.txt
MQL5\Profiles\Tester\Symbols\*.txt
 
fxsaber:

The most convenient way to download tick history (run EA in Terminal).

After that, you can run scripts that work with ticks in the Terminal and not wait a lot of time without signs of life.

This comes in handy for creating custom symbols from the tick history of real symbols. The custom ones will differ from the original ones in that they will have full correspondence of ticks and bars. Thus, there will be no erroneous results of the Tester(example).

 
Unfortunately, it still does not allow to access tick data for several years back from the terminal, even when the tick history is uploaded in the tester. We have to first unload ticks from the tester to a file and then load them into a custom symbol through the terminal. Here is an example of an Expert Advisor that should be run first in the tester in real ticks mode to collect them, and then in the terminal to load them into a custom symbol.
Files:
 
Evgenii Kuznetsov:
Unfortunately, it still does not allow to access tick data for several years back from the terminal, even when the tick history is downloaded in the tester. I have to first unload ticks from the tester into a file and then load them into a custom symbol through the terminal. Here is an example of an Expert Advisor that should be run first in the tester in real ticks mode to collect them, and then in the terminal to load them into a custom symbol.

Your scheme can be implemented by running the Expert Advisor in the Terminal, in which MTTester.mqh will be used.


I have not faced the task of creating a custom symbol from ticks in many years. For a year - did and there without problems Terminal takes ticks. Perhaps you are not requesting in portions and just bogged down by lack of memory when requesting a large interval.

 
In case of memory shortage CopyTicksRange would give -1 and accordingly the error could be found out through GetLastError(), but in my case it just gave 0. Well, the requests were intervals of one month.
 
Evgenii Kuznetsov:
In case of memory shortage CopyTicksRange would give -1 and accordingly the error could be found out through GetLastError(), but in my case it just gave 0. Well, the requests were intervals of one month.

If there will be data for reproduction, the developers will be able to look at it and correct it.

 

Just run any Expert Advisor in the tester in real ticks mode since 2013.

Then run the script in the terminal:

void OnStart(){
   MqlTick Ticks[];
   Print("!!! ",CopyTicksRange(_Symbol, Ticks, COPY_TICKS_ALL, (ulong)D'2013.01.01' * 1000, (ulong)D'2013.02.01' * 1000));
}
 
Evgenii Kuznetsov:

Yes just run any EA in the tester in real ticks mode since 2013.

Then run the script in the terminal:

2020.02.12 16:35:03.435 Test6 (USDSEK,M1)       !!! 2370228