Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 563

 
Roman Sharanov:

and getting data from the indicators, the graph?

Everything is possible. But to do so, you need to be proficient in both languages at least.

 
Artyom Trishkin:

Anything is possible. But to do so, you need to be proficient in both languages at least.

I own

 
Roman Sharanov:

I own

Well then you shouldn't have any trouble writing cross-platform code.

 

Funny situation

A line of code, sometimes causes the error below.

Under what conditions could this error occur?


   ChartTimePriceToXY(0,0,Time[0],price,x1,y_cord);


2018.06.08 13:41:39.021    program name XAUUSDcheck,H1: array out of range in 'DrawInterfaceLib.mqh' (47,31)


 
Sergey Likho:

Funny situation

A line of code, sometimes causes the error below.

Under what conditions could this error occur?


Out of range of an array. The index passed into the array is either greater than the maximum size of the array (if the array is 10, then the maximum index of such an array = 9, because its first element has an index of 0), or less than zero. Either the array has a size of zero.

 
Artyom Trishkin:

Out of range of the array. The index passed into the array is either greater than the maximum size of the array (if the array has size 10, the maximum index of such an array = 9, because its first element has index 0), or less than zero. Either the array has a size of zero.

Thank you, of course, I know that.

Under what conditions could this error occur when accessing theTime[0] array?

So the array is zero? And how can this be the case with time series?

 
Sergey Likho:

Funny situation

A line of code, sometimes causes the error below.

Under what conditions could this error occur?

Old MT4 bug (Time array seems to have zero size). About two years ago, it constantly appeared on one of my clients. But it appeared to be unreal to reproduce this bug. Service Desk acknowledges the problem but is unable to fix it. Since then I never use direct access to timeseries, only through iTime, iOpen, etc.

 
Ihor Herasko:

Old MT4 bug (Time array seems to have a zero size). About two years ago, it kept cropping up on one of my clients. But it turned out to be unreal to reproduce this bug. Service Desk acknowledges the problem but is unable to fix it. Since then I never use direct access to timeseries, only through wrappers: iTime, iOpen etc.

Yes, that's what I ended up doing, replaced with iTime. Thanks!

 

Hello. Out of bounds, how to fix it?

 if(TimeFrame>Period()) 
     {
      ArrayCopySeries(santa1,5,Symbol(),TimeFrame);
      summ=CountBars+TimeFrame/Period();
      shift=0;
      for(int iy=0; shift<summ; shift++) 
        {
         if(Time[shift]<santa1[iy]) iy++;//вот эта строка "array out of range" 
         list[shift]=bufbuy[iy];
        }
     }
 
PolarSeaman:

Hello. Out of bounds, how to fix it?

The values of the shift and iy variables in the above code are not checked to see if they go outside the Time and santa1arrays. Therefore, it makes sense. Check their values before use, the error will disappear.

And to be more specific, you need to know how CountBars and TimeFrame variables are generated.