Experts: Download all ticks of a symbol's history

 

Download all ticks of a symbol's history:

Download all the ticks from your broker for all the symbols in the market watch. Download all history or until a specific date in the past if available.

Author: Lorentzos Roussos

 

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Библиотеки: MultiTester

fxsaber, 2020.01.25 12:39

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

#property description "Закачивает тики через Тестер."

sinput datetime inFromDate = D'2019.01.01'; // С какой даты закачать тики
sinput bool inAllSymbols = false;           // По всем символам (true) или текущему (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 in the Terminal that work with ticks, and not wait a long time without signs of life.

 
fxsaber #:

Nice , thanks

It was hanging on downloads sometimes and the "batching" and "hoping" around charts appears to be solving it as the request was too big for the server , i guess