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

 

Greetings All ! Thank you all in advance !

Bug of this type:

There is a line Low_D1_Level relative to which we are looking in arrayBar_data_D1 [][6]; new levelMin_D_Level

//---global variables

double_D1_Level;

double Bar_data_D1 [][6]; //copies bar data of the specified chart into the array and returns number of copied D1 bars

The first dimension of the array contains the number of bars. The second dimension has 6 elements with the values:

0 - time,
1 - open price,
2 - lowest price (low),
3 - highest price (high),
4 - close price (close),
5 - volume.

//+------------------------------------------------------------------+
//|                        Функция Level 
//+------------------------------------------------------------------+
void Level() 
ArrayCopyRates(Bar_data_D1,_Symbol,PERIOD_D1); // Копирует в массив данные баров указанного графика и возвращает 
Low_D1_Level   = iLow (_Symbol,PERIOD_D1,1);   // Возвращает значение минимальной цены бара  D1
//--- Min_D_Leve  
 for(int i = 1; 0 <= Bar_data_D1 [i][2] ;i++)
    {
     Print(" i = ",i," Bar_data_D1 [i][2] = ",Bar_data_D1 [i][2]);
     if( Bar_data_D1 [i][2] < Low_D1_Level)
       {
        Min_D_Level = Bar_data_D1 [i][2];break;
       }
    } 
//---

Print Print

2020.12.09 15:19:29.109 2016.12.16 00:00:00  _Test EURUSD,H1:  i = 998 Bar_data_D1 [i][2] = 1.3364
2020.12.09 15:19:29.109 2016.12.16 00:00:00  _Test EURUSD,H1:  i = 999 Bar_data_D1 [i][2] = 1.33562
2020.12.09 15:19:29.109 2016.12.16 00:00:00  _Test EURUSD,H1:  i = 1000 Bar_data_D1 [i][2] = 1.33532
2020.12.09 15:19:29.109 2016.12.16 00:00:00  _Test EURUSD,H1:  i = 1001 Bar_data_D1 [i][2] = 1.33705
2020.12.09 15:19:29.109 2016.12.16 00:00:00  _Test EURUSD,H1: array out of range in '_Test.mq4' (451,34)
2020.12.09 15:19:29.110 2016.12.16 00:00:00  Testing pass stopped due to a critical error in the EA
2020.12.09 15:19:29.110 EURUSD,H1: 136637 tick events (25 bars, 63904705 bar states) processed in 0:00:17.844 (total time 0:00:24.547)
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Глобальные переменные создаются путем размещения их объявлений вне описания какой-либо функции. Глобальные переменные определяются на том же уровне, что и функции, т. е. не локальны ни в каком блоке. Область видимости глобальных переменных - вся программа, глобальные переменные доступны из всех функций, определенных в программе...
 
Aliaksei Karalkou:
Please help.

I've tried everything and still get error 130.

Everything works for me, no errors

 

In the strategy tester, run from 2016.12.15.

2016.12.16
 
MakarFX:

It works for me, no errors

Run the optimisation. Optimisation is interrupted by a CriticalError message

 
Aliaksei Karalkou:
Please help.

I've tried everything and still get error 130.

from the fact sheet

 
Dark Kchlyzov:

I don't understand, where does the loop end?

for(int i = 1; 0 <= Bar_data_D1 [i][2] ;i++)

It's supposed to be the last element of the array. No?

And then do a check for inequality

for(int i = 0; i<ArrayRange(Bar_data_D1,0) ;i++)
   {
   if(Bar_data_D1 [i][2]>=0)
      {
      
      }
   }
Then there will be no surprises of going outside the array
 
Aliaksei Karalkou:

Start the optimisation. Optimisation is interrupted by the message CriticalError

No errors, with optimisation from 01.12.2016 to today


 

if you would like to go to https://www.mql5.com/ru/forum/357558

it's all there in detail

Array out of range in Нужна Помощь
Array out of range in Нужна Помощь
  • 2020.12.09
  • www.mql5.com
Приветствую Всех ! Заранее всем спасибо...
 
Dark Kchlyzov:


updated my post
 
Aleksei Stepanenko:

I don't understand, where does the loop end?

It's supposed to be the last element of the array. No?

And then do a check for inequality.

Then there won't be any surprises outside the array
Aleksei Stepanenko:

Excuse me, where does the loop end?

It's supposed to be the last element of the array. No?

And then do a check for inequality.

Then there will be no surprises of going outside the array

Okay, I got it. I'll try it right now.

Thank you!