Errors, bugs, questions - page 2585

 
Nikolai Semko:

Where and at what point do you delete the indicator handle?

As soon as it is no longer needed. And before OnDeinit.

 
fxsaber:

As soon as it was no longer needed. And before OnDeinit.

That's the thing, as soon as it's no longer needed, I delete it. How can I tell a program that it's being removed if OnDeinit doesn't work?

 
Nikolai Semko:

That's the thing, as soon as it's no longer needed, I delete it. How can a program know it's being removed if OnDeinit doesn't work?

Give me the actual task.

 
fxsaber:

The real problem is to tell me the real problem.

The real problem was easily solved by simply avoiding getting your own handle, as you don't need your own handle:

Total = ChartIndicatorsTotal(0,0);
for (int i=0; i<Total; i++) 
  {
      string name=ChartIndicatorName(0,0,i);
      if (name!=MQLInfoString(MQL_PROGRAM_NAME)) 
         handle[i] = ChartIndicatorGet(0,0,name);
  }

just thinking: what if you need your own handle...

there were such problems, but I don't remember them

 
Nikolai Semko:

just thinking: what if you need your own handle...

There were such tasks, but I don't remember them.

Init_Sync has such a need.

 
Roman:

post 25786

By randomization method, I've defined a normal copying into mql's string, a string of const wchar_t* type.
With this parameter in memcpy function, mql started to receive even strings, and without leaks.

memcpy( out, data, wcslen(data) * (sizeof(char)*3) );

That is, instead of 2 bytes sizeof(wchar_t), it used 3 bytes.
The mql string began to correctly take a pointer to the const wchar_t * string.
Is it ok?

But interestingly, the self-described literal string is correctly passed with sizeof(wchar_t).
 
Roman:

Randomly, I defined normal copying to mql string, a string of const wchar_t* type
With such parameter in memcpy function, mql started to receive even strings, and without leaks.

That is, instead of 2 bytes sizeof(wchar_t), it used 3 bytes.
The mql string began to correctly take a pointer to the const wchar_t* string
Is it normal?

But interestingly, the self-written literal string is correctly passed with sizeof(wchar_t).

Why is memcpy used instead of normal wcscpy ?

 
Ilyas:

Why use memcpy instead of the normal wcscpy ?

memcpy was used as shown inRenate's examplearticle.
Using other copy functions causes the same problems.
The behaviour with these functions is described in this post and inthis
All possible copy functions have been tried.

 
I can't read 100000 bars M15 EURUSD from any date in the tester (metaquot demo hedge server)


void OnInit()
  {
    datetime first_date;
   SeriesInfoInteger(_Symbol,_Period,SERIES_FIRSTDATE,first_date);
   int bars=Bars(_Symbol,_Period);
   Print("First date ",first_date," - ",bars," bars");
   
   datetime time[];
   CopyTime(_Symbol,PERIOD_M15,D'2015.01.01',100000,time);
   Print("rows=",100000," =? ",ArraySize(time));
   Print("Load data from ",D'2015.01.01'," =? ",time[0]," to ",time[ArraySize(time)-1],", rows=",100000," =? ",ArraySize(time));
//---

  }
 
void OnTick(){


}

reads about 37,000 bars. When running in the terminal it reads all 100000 bars.


Tried adding paging code from server at https://www.mql5.com/ru/docs/series/timeseries_access#synchronized

But nothing changes.

How to read these 100000 bars in the tester?

Документация по MQL5: Доступ к таймсериям и индикаторам / Организация доступа к данным
Документация по MQL5: Доступ к таймсериям и индикаторам / Организация доступа к данным
  • www.mql5.com
Прежде чем ценовые данные будут доступны в терминале MetaTrader 5, их необходимо получить и обработать. Для получения данных требуется подключение к торговому серверу MetaTrader 5. Данные поступают с сервера по запросу терминала в виде экономно упакованных блоков минутных баров. Механизм обращения к серверу за данными не зависит от того, каким...
 
elibrarius:

How do you calculate these 100,000 bars?

Start by reading the article https://www.mql5.com/ru/articles/239

Основы тестирования в MetaTrader 5
Основы тестирования в MetaTrader 5
  • www.mql5.com
Идея автоматической торговли привлекательна тем, что торговый робот может без устали работать 24 часа в сутки и семь дней в неделю. Робот не знает усталости, сомнений и страха,  ему не ведомы психологические проблемы. Достаточно четко формализовать торговые правила и реализовать их в виде алгоритмов, и робот готов неустанно трудиться. Но прежде...