Errors, bugs, questions - page 437

 
voix_kas:

Sort of cooked it up. Criticism is welcome.

Since it's probably going to be an expert, then:

    bool   SetSymbols(string);

и:

CSymbolList slMain;

int OnInit()
  {
   if(!slMain.SetSymbols(inWorkSymbols)) return(-1);
   for (int i = 0; i < slMain.GetSymbolCount(); i++)
      Print(slMain.GetSymbolName(i));
//--- ok
   return(0);
  }
 
MetaDriver:
I'm betting on that being guaranteed. At least I count on it all the time, and the problem has never arisen.

I see. Anyway, it's a touchy moment.

uncleVic

That's true. But in my case it's redundant:

#include <CSymbolList.mqh>

input int    inTimeToRescan = 3600; // Интервал времени для принудительного пересканирования рабочих инструментов, в секундах
input string inWorkSymbols  = "USDCHF; GBPUSD; EURUSD; USDJPY; USDCAD; AUDUSD; EURGBP; EURAUD; EURCHF; EURJPY; GBPJPY; GBPCHF"; // Рабочие инструменты

CSymbolList slMain;

int OnInit() {
  slMain.SetSymbols(inWorkSymbols);
  return 0;
}

void OnTick() {
  static long LastScan = 0;
  if (!slMain.GetSymbolCount() || ((long)TimeCurrent() - LastScan >= inTimeToRescan)) {
    Comment("Идентификация рабочих инструментов...");
    slMain.SetSymbols(inWorkSymbols);
    LastScan = (long)TimeCurrent();
    return;
  }

  static string Information;
  Information = TimeToString(TimeCurrent(), TIME_DATE|TIME_SECONDS);

  for (int i = 0; i < slMain.GetSymbolCount(); i++) {
    if (!SymbolSelect(slMain.GetSymbolName(i), true) || !SymbolIsSynchronized(slMain.GetSymbolName(i))) continue;
    //
    StringConcatenate(Information, Information, "\n", slMain.GetSymbolName(i));
  }
  Comment(Information);
}

As you can see, if there is an error in the tools in the last cycle in OnTick, there will be no iteration.

 
voix_kas:

I see. Anyway, it's a touchy moment.

uncleVic

That's true. But in my case it's redundant:

As you can see, if there's an error in the tools in the last cycle, there won't be a single iteration in OnTick.

I don't insist. It's just that checking the result of execution is the right thing to do.

 
uncleVic:

I'm not pushing it. Just checking the result of the execution is the right thing to do.

I see. Anyway, thanks for the advice.
 

I've discovered this trick. If you run this script, it "hangs".

void OnStart()
  {
   Print("Start  ",TimeLocal());
   Sleep(-1000*2764799);
   Print("Finish ",TimeLocal());
  }

But if the same three lines (code) are inserted first into OnInit() function of the Expert Advisor and such EA is launched in testing mode, the results are as follows:

NS 0 Core 2 14:23:49 2011.01.03 00:00:00   Ye00-01-2Event5.mq5 OnInit: терминал (470), разрешение на торговлю (true), TERMINAL_MAXBARS=10000000, компилятор (470)
PD 0 Core 2 14:23:49 2011.01.03 00:00:00   Start  2011.01.03 00:00:00
NP 0 Core 2 14:24:18 2011.01.20 17:02:48   Finish 2011.01.20 17:02:48
II 0 Core 2 14:24:18 2011.01.20 17:02:48   MisFunciones.mqh FileInit: Поиск bin-файла Y.bin

First, the code somehow works in testing mode.

Second, (more important), the history of the first few days of testing gets lost. Thus, in the above example, the testing was started on 2011.01.03 (as can be seen from the first two lines), but the tester immediately jumped forward by 17 days after code processing (in this case this is a line 2-3), and testing is continued without taking these 17 days into account.

 
You've just caught an arithmetic overflow in the
 Sleep(-1000*2764799);
resulting in a waiting period of 17.5 days.
 
Renat:
You've just caught an arithmetic overflow in
and have been waiting for 17.5 days.
Yeah, and it works in the tester because it ignores Sleep.
 
Renat:
You have trivially caught an arithmetic overflow in
as a result, you have a 17.5 day wait.

I'm not arguing about "caught overflow", because I don't know :) The question is that such a situation should be suppressed either by compiler or tester with output of critical error (or in some other way). Not everyone will be meticulous about how their programs work in the absence of warnings from the terminal.

The problem is also seen in the fact that the code is placed in OnInit() first lines (i.e. before any historical data is downloaded) - but for some reason, the data of the first 17.5 days are lost.

Документация по MQL5: Программы MQL5 / Ошибки выполнения
Документация по MQL5: Программы MQL5 / Ошибки выполнения
  • www.mql5.com
Программы MQL5 / Ошибки выполнения - Документация по MQL5
 
joo:
Yep, and it works in the tester because Sleep is ignored in it.
Are you so sure that Sleep() is ignored? - Look at the terminal time difference between lines 2 and 3.
 
Yedelkin:
Are you so sure that Sleep() is ignored? - Look at the difference in terminal time between lines 2 and 3.
Perhaps the mere presence of Sleep (as compared to its absence) in the code somehow affects the total execution time, but the fact that Sleep is not counted in the tester is certain.
Reason: