Array out of range in Need of help - page 14

 
Dark Kchlyzov:

Wanted to install an MT4 from an official, and do a test run.

Afternoon. I had a probleminstalling theMT4terminal.I downloaded exactly 4 version from site, it starts to install, but after finishing installation MT5 terminal appears. How do I install exactly MT4?

Answer: You cannot. Support of the previous version is discontinued. Please use MT5.

You can do it


 

Tested over the whole available period

AUDUSD since 2016.01.01

EURUSD since 2011.01.01

GBPUSD since 2011.01.01

used and

 for(int i = 1;  ;i++)

и

 for(int i = 1; i<ArrayRange(Bar_data_D1,0) ;i++)
no errors logs attached
Files:
AUDUSD.log  305 kb
EURUSD.log  612 kb
GBPUSD.log  612 kb
 

The solution

 for(int i = 1; i<ArrayRange(Bar_data_D1,0) ;i++)
   {
   if(Bar_data_D1 [i][2]!=Bar_data_D1 [i+1][2]&&Bar_data_D1 [i][2] < Low_D1_Level)
      {Min_D_Level = Bar_data_D1 [i][2];
      break;}
      
   if(Bar_data_D1 [i][2]==Bar_data_D1 [i+1][2])
      {Min_D_Level = Low_D1_Level;
      break;}
    } 
 

Made an indicator, seems to be drawing everything correctly


 
MakarFX:

Solution

Back to the first page of the post !

2020.12.14 14:23:44.222 Expert Test_Level AUDUSD,H1: removed

2020.12.14 14 14:23:44.234 Expert Test_Level AUDUSD,H1: loaded successfully

2020.12.14 14:23:44.365 TestGenerator: current spread 20 used

2020.12.14 14 14:23:45.263 2020.01.24 00:00:00 Test_Level test started

2020.12.14 14 14:24:29.044 2020.02.10 00:05:00 Test_Level AUDUSD,H1: array out of range in 'Test_Level.mq4' (39,40)

2020.12.14 14 14:24:29.044 2020.02.10 00:05:00 Testing pass stopped due to a critical error in the EA

2020.12.14 14:24:29.044 AUDUSD,H1: 245717 tick events (265 bars, 9638212 bar states) processed in 0:00:43.781 (total time 0:00:44.766)

Removed all unnecessary things, moved function to the body, added your solutions, and again array out of range in 'Test_Level.mq4' (39,40) -:)

everything is OK

And here is actually array out of range in


//+------------------------------------------------------------------+
//|                                                   Test_Level.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "3.0"
#property strict
double    Bar_data_D1 [][6]; // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров D1
double    Low_D1_Level;      // Возвращает значение минимальной цены бара  D1
double    Min_D_Level ;      // ближайшей минимальный  D уровень
int       A_C_R;             // возвращает количество скопированных баров D1
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   DestroyObject();
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
 A_C_R = ArrayCopyRates(Bar_data_D1,_Symbol,PERIOD_D1); // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров
 Low_D1_Level   = iLow (_Symbol,PERIOD_D1,1);           // Возвращает значение минимальной цены бара  D1
 
 //--- Min_D_Leve V 1.2
 for(int i = 1; i<ArrayRange(Bar_data_D1,0) ;i++)
    {
     if(Bar_data_D1 [i][2] != Bar_data_D1 [i+1][2] && Bar_data_D1 [i][2] < Low_D1_Level)
       {
        Min_D_Level = Bar_data_D1 [i][2];break;
       }
      
     if(Bar_data_D1 [i][2] == Bar_data_D1 [i+1][2])
       {
        Min_D_Level = Low_D1_Level;break;
       }
    }
/* 
 //--- Min_D_Leve V 1.0 
 //for(int i = 1; i<ArrayRange(Bar_data_D1,0) ;i++) // так ошибки нет и линия не перерисовывается 
   for(int i = 1; ;i++)                             // а так выход за массив 
    {
     Print(" i = ",i," Bar_data_D1 [i][2] = ",Bar_data_D1 [i][2]);
     if(Bar_data_D1 [i][2]>=0)
       {
        if( Bar_data_D1 [i][2] < Low_D1_Level)
          {
           Min_D_Level = Bar_data_D1 [i][2];break;
          }
       }   
    } 
*/
 //+-------------------------Low_D1_Level----------------------------+ 
 if(ObjectFind("Low_D1")!=Low_D1_Level) 
   {
    ObjectDelete("Low_D1");
    if(ObjectFind("Low_D1")!=0)
      {
       ObjectCreate("Low_D1",OBJ_HLINE, 0, Time[0],Low_D1_Level);
       ObjectSet("Low_D1", OBJPROP_COLOR, clrMaroon);
       ObjectSet("Low_D1", OBJPROP_WIDTH, 1);
      }
   } 
   
 if(ObjectFind("Low_D1_label")!=Low_D1_Level)
   {
    ObjectDelete("Low_D1_label"); 
    if(ObjectFind("Low_D1_label") != 0)
      {
       ObjectCreate("Low_D1_label", OBJ_TEXT, 0, Time[13], Low_D1_Level);
       ObjectSetText("Low_D1_label", "Low_D1: " + DoubleToStr(Low_D1_Level,_Digits), 8,"Verdana", Brown);
      }
   } 
   
 //+-------------------------Min_D_Level----------------------------+ 
 if(ObjectFind("Min_D")!= Min_D_Level) 
   {
    ObjectDelete("Min_D");
    if(ObjectFind("Min_D")!=0)
      {
       ObjectCreate("Min_D",OBJ_HLINE, 0, Time[0],Min_D_Level);
       ObjectSet("Min_D", OBJPROP_COLOR, clrMaroon);
       ObjectSet("Min_D", OBJPROP_WIDTH, 1);
      }
   } 
   
 if(ObjectFind("Min_D_label")!=Min_D_Level)
   {
    ObjectDelete("Min_D_label"); 
    if(ObjectFind("Min_D_label") != 0)
      {
       ObjectCreate("Min_D_label", OBJ_TEXT, 0, Time[30], Min_D_Level);
       ObjectSetText("Min_D_label", "Min_D: " + DoubleToStr(Min_D_Level,_Digits), 8,"Verdana", Brown);
      }
   } 
   Comment(" A_C_R возвращает количество скопированных баров D1 = ",A_C_R); 
}
//+------------------------------------------------------------------+
//|        функция удаление всех объектов созданных советником
//+------------------------------------------------------------------+
void DestroyObject()
{
 int tot=ObjectsTotal();
 for( int i=tot; i>=0; i--)
    {
     
     if(ObjectName(i)=="Low_MN1"){ObjectDelete(0,"Low_MN1");Print("<< Объект Low_MN удалён >>");}
     if(ObjectName(i)=="Low_MN1_label"){ObjectDelete(0,"Low_MN1_label");Print("<< Объект Low_MN1_label удалён >>");}
     

     if(ObjectName(i)=="Min_D"){ObjectDelete(0,"Min_D");Print("<< Объект Min_D удалён >>");}
     if(ObjectName(i)=="Min_D_label"){ObjectDelete(0,"Min_D_label");Print("<< Объект Min_D_label удалён >>");}


   }
}

 
Dark Kchlyzov:

Back from the first page of the post !


Removed all unnecessary, moved function to body , added your solutions and again array out of range in 'Test_Level.mq4' (39,40) -:)

Error with the terminal

copied the code from the post above and ran the test

here is log

Files:
AUDUSD.log  7368 kb
 
I will now try another broker, i.e. another terminal
 
Alpari in 10 years, no mistakes
Files:
Alpari_AUDUSD.log  15491 kb
 
MakarFX:

Error with the terminal

copied the code from the post above and ran the test

here's the log.

Here is the news .

And with the visualization run from 1.01.2020 AUDUSD

I guess it makes no difference .

 

Who is your broker?

What terminal do you use?