array out of range

Back to topics list To post a new topic, please log in or register
avatar
34
texcs 2016.06.15 19:01
 

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
avatar
2017
gooly 2016.06.15 20:27 #
 
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!

avatar
12992
WHRoeder 2016.06.16 13:43 #
 
  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.

Back to topics list  

To add comments, please log in or register