Download MetaTrader 5
To add comments, please log in or register
Any questions regarding MQL5 Cloud Network? FAQ will help you!
falnin
7
falnin 2014.02.06 18:03 

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?

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.06 20:01  
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.
falnin
7
falnin 2014.02.07 09:30  
I suppose I should initialize the array explicitly so in this way, the problem is resolved.
/
To add comments, please log in or register