[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 312

 
Although, it is better to set the size of the array explicitly - or change the size of the array in the code already at the start of the indicator.
 
Oh, and here's another thing. Declaring dimension of 4 cells in one of array dimensions, you cannot call Buffer_OHLC[4][] - the point is that numbering starts with zero, not one. So the maximum you can call is Buffer_OHLC[3][];
 
drknn:


1. The Candles variable is not used anywhere.

2. The line

is not written correctly. It lies in the loop - at each iteration of the loop you create a new variable Cls. And you don't need it there. The following text will suffice.


1. I forgot to point out that the indicator work has not been completed. But in any case this should not affect the operation of this particular function in any way.

2. That's how it was at first. But when it started giving me an error, I thought that the problem might somehow lie in passing data from an array into an array.

 
drknn:

And try the line

replace it with


Didn't help. The error is still the same.
 
drknn:
There is one more thing. If you declared a 4-cell dimension in one of array dimensions, you cannot call Buffer_OHLC[4][] - the point is that the numbering starts with zero, not one. So the maximum you can call is Buffer_OHLC[3][];


The zero cell can also remain empty. A similar example was described in the textbook. Well, in general, even by changing the size of the array, the error remains.

PS The indicator should take data from another tool and apply them to the current one. Perhaps I'm doing something fundamentally wrong when solving this task?

 
silhouette:


The null cell can also remain empty. A similar example was described in the textbook. Well, in general, even after changing the array size, the error persists.

PS The indicator should take data from another tool and apply it to the current tool. Perhaps I am doing something fundamentally wrong when solving this problem?

You are simply not working correctly with a two-dimensional array

 

1. Swap the first index with the second index

2. use ArrayResize

 
silhouette:


The zero cell can also remain empty. A similar example was described in the textbook. Well, in general, even by changing the size of the array, the error remains.

PS The indicator should take data from another tool and apply them to the current one. Perhaps I'm doing something wrong in principle when solving this task?


You declared the Buffer_OHLC[4][] array. You are addressing a non-existent cell of the array, namely, Buffer_OHLC[4][i] - there is no such a cell in the array you have declared. The maximum one there is Buffer_OHLC[3][i].

Let me explain: you declared 4 cells in the second dimension of the array (let's say, 4 rows of some table with an infinite number of columns). Since the numbering starts from zero, the first line that can be accessed is Buffer_OHLC[0][], the second is Buffer_OHLC[1][], the third is Buffer_OHLC[2][], and the fourth is Buffer_OHLC[3][]. The line Buffer_OHLC[4][] does not exist in the array you declared !

 
There also [3,i] does not exist when i>0 :)
 

Don't mind the brakes, it's the first time I've dealt with multidimensional arrays :)

drknn, thank you! I understand your comment

tara:

1. Swap the first index with the second

2. use ArrayResize

Thank you! I have the result. But I would also like to clarify about the ArrayResize function and the size of the first dimension of the array.

   int counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars-1;
   if (limit>1) 
      limit=Bars-1;
   
   ArrayResize(Buffer_OHLC,limit-1);
   for(int i=limit; i>=0; i--)
    {
      Buffer_OHLC[i][0]=iOpen (Smb,Period(),i);
      Buffer_OHLC[i][1]=iHigh (Smb,Period(),i);
      Buffer_OHLC[i][2]=iLow  (Smb,Period(),i);
      Buffer_OHLC[i][3]=iClose(Smb,Period(),i);
      
      if(Line==true)
       {
        Buffer_ind[i]=Buffer_OHLC[i][3];
       }
    }
   return(0);

When using limit-1, there is a graph, but the 4051 "Invalid value of function parameter" error pops up.

Reason: