array out of range

 

The code excerpt from where the error is this

 

   for (i = Bars; i >= 0; i--) {
      TrendUp[i] = EMPTY_VALUE;
      TrendDown[i] = EMPTY_VALUE;
      atr = iATR(NULL, 0, 10, i);
      medianPrice = (High[i]+Low[i])/2;
      up[i]=medianPrice+(Multiplier*atr);
      dn[i]=medianPrice-(Multiplier*atr);
      trend[i]=1;

The lines which gives the error are these
      TrendUp[i] = EMPTY_VALUE;
      TrendDown[i] = EMPTY_VALUE;"

 

Do you think why? then one thing is strange if I do run into a mql file with only the function code nn problems if I put it in a file with other code gives me the problem


I hope for an answer
 
texcs:

The code excerpt from where the error is this

 

   for (i = Bars; i >= 0; i--) {
      TrendUp[i] = EMPTY_VALUE;
      TrendDown[i] = EMPTY_VALUE;
      atr = iATR(NULL, 0, 10, i);
      medianPrice = (High[i]+Low[i])/2;
      up[i]=medianPrice+(Multiplier*atr);
      dn[i]=medianPrice-(Multiplier*atr);
      trend[i]=1;

The lines which gives the error are these
      TrendUp[i] = EMPTY_VALUE;
      TrendDown[i] = EMPTY_VALUE;"

 

Do you think why? then one thing is strange if I do run into a mql file with only the function code nn problems if I put it in a file with other code gives me the problem


I hope for an answer

Have you checked the your access to your array, the size of the array?

PLS use the SRC-button if you post code!

 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. for (i = Bars; i >= 0; i--) {
          TrendUp[i] = EMPTY_VALUE;
    Assuming TrendUp is a buffer it's size is always Bars. That means the index is [Bars-1 .. 0], [Bars] does not exist, array out of range.
  3. Your lookback is 10 (iATR(NULL,0, 10, i) Do your lookbacks correctly.
Reason: