Errors, bugs, questions - page 595

 
-Alexey-:
Try to transfer to C - the error will find itself. And in general - with such projects it's the only way to write, if you don't want problems in the future. Unfortunately, I myself have understood it too late and now rewrite it :).
Probably I will study C++ in the nearest future. During last six months my head is already full: MQL4, MQL5, HTML, CSS, XML. And now I'm studying JavaScript as well. I don't have enough space and time for C++ yet, though I really want to)).
 

We have an indicator running on TF M15, in the code the indicator requests the time series MqlRates from TF M1.

The indicator does not start at once as M1 data is not ready and it is not possible to load it during the first run.

As a result we have a fake pass and the indicator does not access the data anymore, thinking that it is already calculated and there is no need to recalculate it.

Now I am running the indicator in two ways:

  1. I start the indicator on M15, delete the indicator and start it again (it works).
  2. Before running the indicator on M15 I open a chart on M1, run the indicator on M15 (everything works the first time).

Hence the question: how to automate the correct checking and loading of the required data for another TF?

 
Urain:

Hence the question: how to automate the checking and loading of the required data from the other TF?

In a similar situation, I control the initialisation process in OnCalculate. If there is an error during initialization, then I return prev_calculated=0, and so on until everything is counted correctly.
 
Lizar:
In a similar situation, I control the initialization process in OnCalculate. If there is an error during initialization, then I return prev_calculated=0 and keep doing it until everything is calculated correctly.

The idea is good, although nothing can be assigned to prev_calculated, the variable is declared as const, but I understand you can have another similar variable.

There is still one question - if there is no data, what should I do?

I understand that request for data itself doesn't lead to downloading or uploading from local database, and this is exactly the problem.

 
Urain:

The idea is good, although you can't assign anything to prev_calculated, the variable is declared as const, but I understood you, you can have another similar variable.

It's not about assignment, it's about the number returned by OnCalculated. If your data is not ready, you will return 0 from OnCalculated.
Look at the examples of BarsCalculated. That's how you should check.

One question remains - if there is no data, what should you do?

If there is no data and it won't appear, then there's not much to do.
If you want, you can wait and calculate buffers by timer.
 
sergeev:

If your data is not ready, you will return 0 from OnCalculated.
Look at the examples of BarsCalculated.

If you don't have them and they won't appear, then there's not much to do.
If you want, you can call waiting and calculating buffers by timer.

It does not help, only unloading the indicator and restarting it, in this case the data is already there for some reason.

Or alternatively, open a chart with the required M1 TF, then the data on the adjacent M15 chart on M1 request is ready immediately.

 
Urain:

It doesn't help, only unloading the indicator and restarting it, in this case the data is already there for some reason.

Or alternatively, open a chart with the required TF, then the data on the adjacent chart is ready at once.

Today I spent half a day with indices. There were multicurrency/multitime.

The problem with not displaying is that you are trying to take a value from a bar that simply does not exist in this TF.

So you have to check before taking a bar - SeriesInfoInteger.
No unloading needed. You won't unload the calculation part anyway (I just raised the topic on this today).
 
sergeev:

I've been working with the indices for half a day today. There were multicurrency/multitime.

The problem with the non-displaying is that it tries to take the value from a bar that just does not exist in this TF.

So you have to check before taking a bar - SeriesInfoInteger.

No unloading needed. You can't unload the calculation part anyway (I just brought up a topic on this today).

Mimeo, I have a checker, I find the first date on TF M1 and the calculation of M15 bars starts from this date. TF is set as PERIOD_M1

   timestart=(datetime)SeriesInfoInteger(_Symbol,TF,SERIES_FIRSTDATE);
   for(int i=prev>0?prev-1:0;i<rates_total-1;i++)
     {
      if(time[i]>timestart)
        {
         ... расчёт
        }
     }
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков - Документация по MQL5
 
Urain:

1. the idea is good, although nothing can be assigned to prev_calculated, the variable is declared as const, but I understand you can have another similar variable.

2. one question remains, and if there is no data, what should we do?

3. I understand that the data request itself does not cause the data to be downloaded or uploaded from the local database, and this is exactly the problem.

  1. I meant fromOnCalculate return 0, then prev_calculated=0;
  2. I set counter of re-initializations. At overflow, I unload indicator.
  3. I had no problems with SoruXXX. If there is a local history, everything counted from the second or third time, if not from the first. At the Championship, the "spy" used by the Expert Advisor counts only on the one-minute history, it works on H1. And so on 9 pairs. If there is no local history at all, point 2 will work. But, as far as I remember, history was downloaded from the server.
 
Urain:

I understand that the data request itself doesn't cause data downloading or uploading from local database, and this is exactly the problem.

From the CopyXXXX help:

When requesting data from an Expert Advisor or a script, it will initiate downloading from the server, if the terminal does not have these data locally, or it will start building the required timeseries, if the data can be built from the local history, but they are not ready yet. The function will return the amount of data that will be ready when the timeout expires, but history will continue to be downloaded and the next similar request will return more data.

We are talking only about Expert Advisors and scripts. Does this not apply to indicators?