FOR loop not works in my Expert code

 

Hi All,

I wrote a piece of code for mql4 in metatrader platform to do trade automatically. but surprisingly I don't know that it doesn't work. I've understood 2 things in my expert code:

1. the For loop just repeat one or two times instead of "UpperBound" variable.

2. in the log, I can see that the For loop goes beyond the "UpperBould".

extern int       minFStablePeriod=10;
extern double    minFBarLength=0.60;

int start()
  {
      
   double ShortF[] = {};
   double LongF[] = {};
   bool SignF[] = {};

   int i;
   for(i=0; i<minFStablePeriod; i++)
      {
         ShortF[i] = iCustom(NULL,0,"F1",10,0,i);
         LongF[i] = iCustom(NULL,0,"F1",55,0,i);
         Print(DoubleToStr(ShortF[i],4));
         if(ShortF[i] > minFBarLength)
            { SignF[i] = (ShortF[i] > minFBarLength) && (LongF[i] > minFBarLength); }
         else if(ShortF[i] < -minFBarLength)
            { SignF[i] = (ShortF[i] < -minFBarLength) && (LongF[i] < -minFBarLength); }
         else
            {
               Print("F indicator: Value less than Min [" + i+1 + ":" + minFStablePeriod + "] [" + DoubleToStr(ShortF[i],4) + ":" + DoubleToStr(minFBarLength,2) + "]");
               return(0);
            }
            
         if(SignF[i] == False)
            {
               Print("F indicator: No opportunity");
               return(0);
            }      
      }
  }

in the print function, I've got 1 or 11 but the minFStablePeriod=10.

Could you help me to solve the problem?

 
falconin:

Hi All,

I wrote a piece of code for mql4 in metatrader platform to do trade automatically. but surprisingly I don't know that it doesn't work. I've understood 2 things in my expert code:

1. the For loop just repeat one or two times instead of "UpperBound" variable.

2. in the log, I can see that the For loop goes beyond the "UpperBould".

in the print function, I've got 1 or 11 but the minFStablePeriod=10.

Could you help me to solve the problem?

Your arrays look like they have a size of zero elements to me . . . but I can't be sure with the new mql4.
 
I suppose I should initialize the array explicitly so in this way, the problem is resolved.