Array out of range in Need of help - page 15

 

MetaQuotes with visualisation

2020.12.14 10:55:49.261 AUDUSD,H1: 61687 tick events (61686 bars, 124333 bar states) processed in 0:00:38.188 (total time 0:00:38.203)
2020.12.14 10:55:49.261 2020.12.11 23:59:59  Array2 AUDUSD,H1: << Объект Min_D удалён >>
2020.12.14 10:55:49.261 2020.12.11 23:59:59  Array2 AUDUSD,H1: << Объект Min_D_label удалён >>
2020.12.14 10:55:49.261 2020.12.11 23:59:59  Array2 AUDUSD,H1:  i = 2/ Min_D_Level = 0.74038/ Low_D1_Level0.74233/ Разница0.00195
2020.12.14 10:55:49.261 2020.12.11 23:00:00  Array2 AUDUSD,H1:  i = 2/ Min_D_Level = 0.74038/ Low_D1_Level0.74233/ Разница0.00195

Alpari with visualisation

2020.12.14 10:56:13.369 AUDUSD,H1: 129781 tick events (129780 bars, 260520 bar states) processed in 0:01:16.688 (total time 0:01:16.719)
2020.12.14 10:56:13.369 2020.12.11 23:59:59  Array2 AUDUSD,H1: << Объект Min_D удалён >>
2020.12.14 10:56:13.369 2020.12.11 23:59:59  Array2 AUDUSD,H1: << Объект Min_D_label удалён >>
2020.12.14 10:56:13.369 2020.12.11 23:59:59  Array2 AUDUSD,H1:  i = 2/ Min_D_Level = 0.74039/ Low_D1_Level0.74234/ Разница0.00195
2020.12.14 10:56:13.369 2020.12.11 23:00:00  Array2 AUDUSD,H1:  i = 2/ Min_D_Level = 0.74039/ Low_D1_Level0.74234/ Разница0.00195
 
Dark Kchlyzov :

Here is the Function to be debugged Post#43

That's how it works)))

 //+------------------------------------------------------------------+
//|                                                   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    "1.00"
#property strict
double    Bar_data_D1 [][ 6 ]; // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров D1
double    Bar_data_W1 [][ 6 ]; // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров W1
double    Bar_data_MN [][ 6 ];
double    High_D1_Level;     // Возвращает значение максимальной цены бара D1
double    Low_D1_Level;       // Возвращает значение минимальной цены бара  D1
double    High_W1_Level;     // Возвращает значение максимальной цены бара W1
double    Low_W1_Level ;     // Возвращает значение минимальной цены бара  W1
double    High_MN1_Level;     // Возвращает значение максимальной цены бара MN1
double    Low_MN1_Level;     // Возвращает значение минимальной цены бара  MN1
double    Max_D_Level;       // ближайшей максимальный D уровень
double    Min_D_Level ;       // ближайшей минимальный  D уровень
double    Max_W_Level ;       // ближайшей максимальный W уровень
double    Min_W_Level ;       // ближайшей минимальный  W уровень
double    Max_MN_Level ;     // ближайшей максимальный MN уровень
double    Min_MN_Level ;     // ближайшей минимальный  MN уровень

int       Max_D_Num ;         // ближайшей максимальный день (номер бара)  
int       Min_D_Num ;         // ближайшей минимальный  день (номер бара)
int       Max_D_Volume ;     // ближайшей максимальный день (Объём)  
int       Min_D_Volume ;     // ближайшей минимальный  день (Объём)
datetime Max_D_Time;         // 
datetime Min_D_Time;         //
datetime Time_Day;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
   Level();
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
   ObjectsDeleteAll ( 0 , "Arr_" ); Print ( "<< Все объекты удалены >>" );
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
  On_Timer();
  }
//+------------------------------------------------------------------+
//|                        Функция Level v 1.0
//+------------------------------------------------------------------+
void Level()
{
 ArrayCopyRates(Bar_data_D1, _Symbol , PERIOD_D1 ); // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров
 ArrayCopyRates(Bar_data_W1, _Symbol , PERIOD_W1 ); // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров
 ArrayCopyRates(Bar_data_MN, _Symbol , PERIOD_MN1 ); // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров
 
 High_D1_Level  = iHigh ( _Symbol , PERIOD_D1 , 1 );   // Возвращает значение максимальной цены бара D1
 Low_D1_Level   = iLow ( _Symbol , PERIOD_D1 , 1 );   // Возвращает значение минимальной цены бара  D1
 High_W1_Level  = iHigh ( _Symbol , PERIOD_W1 , 1 );   // Возвращает значение максимальной цены бара W1
 Low_W1_Level   = iLow ( _Symbol , PERIOD_W1 , 1 );   // Возвращает значение минимальной цены бара  W1 
 High_MN1_Level = iHigh ( _Symbol , PERIOD_MN1 , 1 );   // Возвращает значение максимальной цены бара MN1
 Low_MN1_Level  = iLow ( _Symbol , PERIOD_MN1 , 1 );   // Возвращает значение минимальной цены бара  MN1
 
//--- Max_D_Level
 for ( int i = 1 ; i< ArrayRange (Bar_data_D1, 0 ) ;i++)
    {
     if (Bar_data_D1 [i][ 3 ] != Bar_data_D1 [i+ 1 ][ 3 ])
       {
         if (Bar_data_D1 [i][ 3 ] > High_D1_Level)  
          {
           Max_D_Level = Bar_data_D1 [i][ 3 ];
           Print ( " i = " ,i, "/Max_D Разница" , DoubleToString (Max_D_Level-High_D1_Level, Digits ));
           break ;
          }
       }
     if (Bar_data_D1 [i][ 3 ] == Bar_data_D1 [i+ 1 ][ 3 ])
       {
        Max_D_Level = High_D1_Level;
         Print ( " i = " ,i, "/Max_D Разница" , DoubleToString (Max_D_Level-High_D1_Level, Digits ));
         break ;
       }
    } 
    
//--- Min_D_Leve  
 for ( int i = 1 ; i< ArrayRange (Bar_data_D1, 0 ) ;i++)
    {
     if (Bar_data_D1 [i][ 2 ] != Bar_data_D1 [i+ 1 ][ 2 ])
       {
         if ( Bar_data_D1 [i][ 2 ] < Low_D1_Level)
          {
           Min_D_Level = Bar_data_D1 [i][ 2 ];
           Print ( " i = " ,i, "/Min_D Разница" , DoubleToString (Low_D1_Level-Min_D_Level, Digits ));
           break ;
          }
       }   
     if (Bar_data_D1 [i][ 2 ] == Bar_data_D1 [i+ 1 ][ 2 ])
       {
        Min_D_Level = Low_D1_Level;
         Print ( " i = " ,i, "/Min_D Разница" , DoubleToString (Low_D1_Level-Min_D_Level, Digits ));
         break ;
       }
    } 
    
    
//--- Max_W_Level
 for ( int i = 1 ; i< ArrayRange (Bar_data_D1, 0 ) ;i++)
    {
     //Print(" i = ",i);
     if (Bar_data_W1 [i][ 3 ] != Bar_data_W1 [i+ 1 ][ 3 ])
       {
         if (Bar_data_W1 [i][ 3 ] > High_W1_Level)    
          {
           Max_W_Level = Bar_data_W1 [i][ 3 ];
           Print ( " i = " ,i, "/Max_W Разница" , DoubleToString (Max_W_Level-High_W1_Level, Digits ));
           break ;
          }
       }  
     if (Bar_data_W1 [i][ 3 ] == Bar_data_W1 [i+ 1 ][ 3 ])
       {
        Max_W_Level = High_W1_Level;
         Print ( " i = " ,i, "/Max_W Разница" , DoubleToString (Max_W_Level-High_W1_Level, Digits ));
         break ;
       }
    } 
    
//--- Min_W_Level 
 for ( int i = 1 ; i< ArrayRange (Bar_data_D1, 0 ) ;i++)
    {
     // Print(" i = ",i);
     if (Bar_data_W1 [i][ 2 ] != Bar_data_W1 [i+ 1 ][ 2 ])
       {
         if (Bar_data_W1 [i][ 2 ] < Low_W1_Level)
          {
           Min_W_Level = Bar_data_W1 [i][ 2 ];
           Print ( " i = " ,i, "/Min_W Разница" , DoubleToString (Low_W1_Level-Min_W_Level, Digits ));
           break ;
          }
       }  
     if (Bar_data_W1 [i][ 2 ] == Bar_data_W1 [i+ 1 ][ 2 ])
       {
        Min_W_Level = Low_W1_Level;
         Print ( " i = " ,i, "/Min_W Разница" , DoubleToString (Low_W1_Level-Min_W_Level, Digits ));
         break ;
       }
    } 

 //+-----------------------High_D1_Level-----------------------------+  
 if ( ObjectFind ( "Arr_High_D1" )!=High_D1_Level) 
   {
     ObjectDelete ( "Arr_High_D1" );
     if ( ObjectFind ( "Arr_High_D1" )!= 0 )
      {
       ObjectCreate ( "Arr_High_D1" , OBJ_HLINE , 0 , Time[ 0 ],High_D1_Level);
       ObjectSet( "Arr_High_D1" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_High_D1" , OBJPROP_WIDTH , 1 );
      }
   } 
 if ( ObjectFind ( "Arr_High_D1_label" )!=High_D1_Level)
   {
     ObjectDelete ( "Arr_High_D1_label" ); 
     if ( ObjectFind ( "Arr_High_D1_label" ) != 0 )
      {
       ObjectCreate ( "Arr_High_D1_label" , OBJ_TEXT , 0 , Time[ 13 ], High_D1_Level);
       ObjectSetText( "Arr_High_D1_label" , "High_D1: " + DoubleToStr(High_D1_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   } 
 //+-------------------------Low_D1_Level----------------------------+ 
 if ( ObjectFind ( "Arr_Low_D1" )!=Low_D1_Level) 
   {
     ObjectDelete ( "Arr_Low_D1" );
     if ( ObjectFind ( "Arr_Low_D1" )!= 0 )
      {
       ObjectCreate ( "Arr_Low_D1" , OBJ_HLINE , 0 , Time[ 0 ],Low_D1_Level);
       ObjectSet( "Arr_Low_D1" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Low_D1" , OBJPROP_WIDTH , 1 );
      }
   } 
   
 if ( ObjectFind ( "Arr_Low_D1_label" )!=Low_D1_Level)
   {
     ObjectDelete ( "Arr_Low_D1_label" ); 
     if ( ObjectFind ( "Arr_Low_D1_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Low_D1_label" , OBJ_TEXT , 0 , Time[ 13 ], Low_D1_Level);
       ObjectSetText( "Arr_Low_D1_label" , "Low_D1: " + DoubleToStr(Low_D1_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   } 
   
     //+-----------------------Max_D_Level-----------------------------+  
 if ( ObjectFind ( "Arr_Lax_D" )!=Max_D_Level) 
   {
     ObjectDelete ( "Arr_Lax_D" );
     if ( ObjectFind ( "Arr_Lax_D" )!= 0 )
      {
       ObjectCreate ( "Arr_Lax_D" , OBJ_HLINE , 0 , Time[ 0 ],Max_D_Level);
       ObjectSet( "Arr_Lax_D" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Lax_D" , OBJPROP_WIDTH , 1 );
      }
   } 
 if ( ObjectFind ( "Arr_Lax_D_label" )!=Max_D_Level)
   {
     ObjectDelete ( "Arr_Lax_D_label" ); 
     if ( ObjectFind ( "Arr_Lax_D_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Lax_D_label" , OBJ_TEXT , 0 , Time[ 30 ], Max_D_Level);
       ObjectSetText( "Arr_Lax_D_label" , "Max_D: " + DoubleToStr(Max_D_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   } 
 //+-------------------------Min_D_Level----------------------------+ 
 if ( ObjectFind ( "Arr_Lin_D" )!= Min_D_Level) 
   {
     ObjectDelete ( "Arr_Lin_D" );
     if ( ObjectFind ( "Arr_Lin_D" )!= 0 )
      {
       ObjectCreate ( "Arr_Lin_D" , OBJ_HLINE , 0 , Time[ 0 ],Min_D_Level);
       ObjectSet( "Arr_Lin_D" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Lin_D" , OBJPROP_WIDTH , 1 );
      }
   } 
   
 if ( ObjectFind ( "Arr_Lin_D_label" )!=Min_D_Level)
   {
     ObjectDelete ( "Arr_Lin_D_label" ); 
     if ( ObjectFind ( "Arr_Lin_D_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Lin_D_label" , OBJ_TEXT , 0 , Time[ 30 ], Min_D_Level);
       ObjectSetText( "Arr_Lin_D_label" , "Min_D: " + DoubleToStr(Min_D_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   }  
 //+-----------------------High_W1_Level-----------------------------+         
 if ( ObjectFind ( "Arr_High_W1" )!=High_W1_Level) 
   {
     ObjectDelete ( "Arr_High_W1" );
     if ( ObjectFind ( "Arr_High_W1" )!= 0 )
      {
       ObjectCreate ( "Arr_High_W1" , OBJ_HLINE , 0 , Time[ 0 ],High_W1_Level);
       ObjectSet( "Arr_High_W1" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_High_W1" , OBJPROP_WIDTH , 1 );
      }
   } 
 if ( ObjectFind ( "Arr_High_W1_label" )!=High_W1_Level)
   {
     ObjectDelete ( "Arr_High_W1_label" ); 
     if ( ObjectFind ( "Arr_High_W1_label" ) != 0 )
      {
       ObjectCreate ( "Arr_High_W1_label" , OBJ_TEXT , 0 , Time[ 47 ], High_W1_Level);
       ObjectSetText( "Arr_High_W1_label" , "High_W1: " + DoubleToStr(High_W1_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   } 
 //+-------------------------Low_W1_Level----------------------------+       
 if ( ObjectFind ( "Arr_Low_W1" )!=Low_W1_Level) 
   {
     ObjectDelete ( "Arr_Low_W1" );
     if ( ObjectFind ( "Arr_Low_W1" )!= 0 )
      {
       ObjectCreate ( "Arr_Low_W1" , OBJ_HLINE , 0 , Time[ 0 ],Low_W1_Level);
       ObjectSet( "Arr_Low_W1" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Low_W1" , OBJPROP_WIDTH , 1 );
      }
   } 
   
 if ( ObjectFind ( "Arr_Low_W1_label" )!=Low_W1_Level)
   {
     ObjectDelete ( "Arr_Low_W1_label" ); 
     if ( ObjectFind ( "Arr_Low_W1_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Low_W1_label" , OBJ_TEXT , 0 , Time[ 47 ], Low_W1_Level);
       ObjectSetText( "Arr_Low_W1_label" , "Low_W1: " + DoubleToStr(Low_W1_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   }  
   
   
 //+-----------------------Max_W_Level-----------------------------+         
 if ( ObjectFind ( "Arr_Lax_W" )!=Max_W_Level) 
   {
     ObjectDelete ( "Arr_Lax_W" );
     if ( ObjectFind ( "Arr_Lax_W" )!= 0 )
      {
       ObjectCreate ( "Arr_Lax_W" , OBJ_HLINE , 0 , Time[ 0 ],Max_W_Level);
       ObjectSet( "Arr_Lax_W" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Lax_W" , OBJPROP_WIDTH , 1 );
      }
   } 
 if ( ObjectFind ( "Arr_Lax_W_label" )!= Max_W_Level)
   {
     ObjectDelete ( "Arr_Lax_W_label" ); 
     if ( ObjectFind ( "Arr_Lax_W_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Lax_W_label" , OBJ_TEXT , 0 , Time[ 64 ], Max_W_Level);
       ObjectSetText( "Arr_Lax_W_label" , "Max_W: " + DoubleToStr(Max_W_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   } 
 //+-------------------------Min_W_Level----------------------------+       
 if ( ObjectFind ( "Arr_Lin_W" )!=Min_W_Level) 
   {
     ObjectDelete ( "Arr_Lin_W" );
     if ( ObjectFind ( "Arr_Lin_W" )!= 0 )
      {
       ObjectCreate ( "Arr_Lin_W" , OBJ_HLINE , 0 , Time[ 0 ],Min_W_Level);
       ObjectSet( "Arr_Lin_W" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Lin_W" , OBJPROP_WIDTH , 1 );
      }
   } 
   
 if ( ObjectFind ( "Arr_Lin_W_label" )!= Min_W_Level)
   {
     ObjectDelete ( "Arr_Lin_W_label" ); 
     if ( ObjectFind ( "Arr_Lin_W_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Lin_W_label" , OBJ_TEXT , 0 , Time[ 64 ], Min_W_Level);
       ObjectSetText( "Arr_Lin_W_label" , "Min_W: " + DoubleToStr(Min_W_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   }
 //+-----------------------High_MN1_Level-----------------------------+         
 if ( ObjectFind ( "Arr_High_MN1" )!=High_MN1_Level) 
   {
     ObjectDelete ( "Arr_High_MN1" );
     if ( ObjectFind ( "Arr_High_MN1" )!= 0 )
      {
       ObjectCreate ( "Arr_High_MN1" , OBJ_HLINE , 0 , Time[ 0 ],High_MN1_Level);
       ObjectSet( "Arr_High_MN1" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_High_MN1" , OBJPROP_WIDTH , 1 );
      }
   } 
 if ( ObjectFind ( "Arr_High_MN1_label" )!=High_MN1_Level)
   {
     ObjectDelete ( "Arr_High_MN1_label" ); 
     if ( ObjectFind ( "Arr_High_MN1_label" ) != 0 )
      {
       ObjectCreate ( "Arr_High_MN1_label" , OBJ_TEXT , 0 , Time[ 81 ], High_MN1_Level);
       ObjectSetText( "Arr_High_MN1_label" , "High_MN1: " + DoubleToStr(High_MN1_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   } 
 //+-------------------------Low_MN1_Level----------------------------+       
 if ( ObjectFind ( "Arr_Low_MN1" )!=Low_MN1_Level) 
   {
     ObjectDelete ( "Arr_Low_MN1" );
     if ( ObjectFind ( "Arr_Low_MN1" )!= 0 )
      {
       ObjectCreate ( "Arr_Low_MN1" , OBJ_HLINE , 0 , Time[ 0 ],Low_MN1_Level);
       ObjectSet( "Arr_Low_MN1" , OBJPROP_COLOR , clrMaroon );
       ObjectSet( "Arr_Low_MN1" , OBJPROP_WIDTH , 1 );
      }
   } 
   
 if ( ObjectFind ( "Arr_Low_MN1_label" )!=Low_MN1_Level)
   {
     ObjectDelete ( "Arr_Low_MN1_label" ); 
     if ( ObjectFind ( "Arr_Low_MN1_label" ) != 0 )
      {
       ObjectCreate ( "Arr_Low_MN1_label" , OBJ_TEXT , 0 , Time[ 81 ], Low_MN1_Level);
       ObjectSetText( "Arr_Low_MN1_label" , "Low_MN1: " + DoubleToStr(Low_MN1_Level, _Digits ), 8 , "Verdana" , Brown);
      }
   }       
}
//+-------------------------------------------------------------------------+   
//                         функция Timer                    
//+-------------------------------------------------------------------------+
void On_Timer()
{

     
 if (Day()!= Time_Day)
   {
    Level();
    Time_Day = Day();
   }
}
 
MakarFX:

That's how it works)))

There are errors in the code:

 for(int i = 1; i<ArrayRange(Bar_data_D1,0) ;i++)
    {
     //Print(" i = ",i);
     if(Bar_data_W1 [i][3] != Bar_data_W1 [i+1][3])
       {
        if(Bar_data_W1 [i][3] > High_W1_Level)    
          {
           Max_W_Level = Bar_data_W1 [i][3];
           Print(" i = ",i,"/Max_W Разница",DoubleToString(Max_W_Level-High_W1_Level,Digits));
           break;
          }
       }  
     if(Bar_data_W1 [i][3] == Bar_data_W1 [i+1][3])
       {
        Max_W_Level = High_W1_Level;
        Print(" i = ",i,"/Max_W Разница",DoubleToString(Max_W_Level-High_W1_Level,Digits));
        break;
       }
    } 

We loop through one array and address items of another one. When the number of items in Bar_data_D1 exceeds the number of items in Bar_data_W1 and we address such an item, the array is overrun.

 
Dark Kchlyzov:

I think so, so you can go backwards, in my case two months from the date of the test

The tester sees 1002 daily bars


The tester adds 1000 candlesticks before the test interval start date, earlier history is not taken into account. I need to make a big test interval. I have it starting from 2000.

 
Aleksei Stepanenko:

There are errors in the code:

We loop through one array and address items of another one. When the number of items in Bar_data_D1 exceeds the number of items in Bar_data_W1, the array is overrun.

fixed

//--- Max_W_Level
 for(int i = 1; i<ArrayRange(Bar_data_W1,0) ;i++)
    {
     if(Bar_data_W1 [i][3] != Bar_data_W1 [i+1][3])
       {
        if(Bar_data_W1 [i][3] > High_W1_Level)    
          {
           Max_W_Level = Bar_data_W1 [i][3];
           Print(" i = ",i,"/Max_W Разница",DoubleToString(Max_W_Level-High_W1_Level,Digits));
           break;
          }
       }  
     if(Bar_data_W1 [i][3] == Bar_data_W1 [i+1][3])
       {
        Max_W_Level = High_W1_Level;
        Print(" i = ",i,"/Max_W Разница",DoubleToString(Max_W_Level-High_W1_Level,Digits));
        break;
       }
    } 
    
//--- Min_W_Level 
 for(int i = 1; i<ArrayRange(Bar_data_W1,0) ;i++)
    {
     if(Bar_data_W1 [i][2] != Bar_data_W1 [i+1][2])
       {
        if(Bar_data_W1 [i][2] < Low_W1_Level)
          {
           Min_W_Level = Bar_data_W1 [i][2];
           Print(" i = ",i,"/Min_W Разница",DoubleToString(Low_W1_Level-Min_W_Level,Digits));
           break;
          }
       }  
     if(Bar_data_W1 [i][2] == Bar_data_W1 [i+1][2])
       {
        Min_W_Level = Low_W1_Level;
        Print(" i = ",i,"/Min_W Разница",DoubleToString(Low_W1_Level-Min_W_Level,Digits));
        break;
       }
    } 

works with no errors

2020.12.14 13:02:09.812 AUDUSD,H1: 5902 tick events (5901 bars, 12803 bar states) processed in 0:00:00.125 (total time 0:00:00.125)
2020.12.14 13:02:09.812 2020.12.11 23:59:59  Array3 AUDUSD,H1: << Все объекты удалены >>
2020.12.14 13:02:09.812 2020.12.11 00:00:00  Array3 AUDUSD,H1:  i = 2/Min_W Разница0.00738
2020.12.14 13:02:09.812 2020.12.11 00:00:00  Array3 AUDUSD,H1:  i = 3/Max_W Разница0.00000
2020.12.14 13:02:09.812 2020.12.11 00:00:00  Array3 AUDUSD,H1:  i = 2/Min_D Разница0.00195
2020.12.14 13:02:09.812 2020.12.11 00:00:00  Array3 AUDUSD,H1:  i = 264/Max_D Разница0.00000
 
Aleksei Stepanenko:

There are errors in the code:

We loop through one array and address items of another one. When the number of items in Bar_data_D1 is larger than in Bar_data_W1 and we address such an item, the array is overrun.

This is not an error but carelessness, just when you are sitting puzzling over what the problem is, you delete and copy and then someone comes and says what the problem is (without even reading the code) you just take it and throw it out, that's the result.

 
MakarFX:

Error with the terminal

copied the code from the post above and ran the test

here is a log

Tear down terminal and reinstall ?

Maybe with hardware ? or scooter ?

 
Dark Kchlyzov:

It is not an error but carelessness, when you are sitting there wondering what the problem is, you delete and copy and then someone comes and says what the problem is (without reading) you just take it and throw it out, that's the result.

You don't leave old versions behind.

And the code compares adjacent values, is this correct and consistent with the original picture and the problem?

if(Bar_data_W1 [i][3] == Bar_data_W1 [i+1][3])

It's a search for identical adjacent values, a simpler task, not all identical values. Head-on search for copies (same values) is done by comparing each element in the array against all, it's expensive, there are other more sophisticated but cheaper solutions.

I don't like it, but without major changes to your code, before such a comparison, sort the array by the searched value, and then the code will be more correct.

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Переменные - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Dark Kchlyzov:

Tear down the terminal and reinstall ?

Maybe with the hardware ? or the scooter ?

Different behaviour on the same period under the same conditions (same data provider) ?

 
MakarFX:

Who is your broker?

What terminal do you use?

Does anyone have an MT4 terminal from the MT4 developers?

Reason: