Download MetaTrader 5

Array not work with new build.

To add comments, please log in or register
Mohammad Ali
21276
Mohammad Ali  

Dear Guys,

Below code not work with new build. but it work on old MQL. in Alert Indi1DayMoArray[1] show nothing. but it should be show "08:00:59"

string Indi3_Day_Mo   = "04:30:59;08:00:59;16:23:59";
string Indi1DayMoArray[20];

void MakeAllTime(string LotsProgression, string &TimeSet[]){
   int i,j,k;
   string ls;
   //ArrayInitialize(TimeSet,100);
   while (true) {
        j=StringFind(LotsProgression,";",i);
        if (j>0) {
                ls=StringSubstr(LotsProgression,i,j-i);
                i=j+1;
                k++;
                ArrayResize(TimeSet,k);
                Alert(ls);
                TimeSet[k-1]=ls;
        } else {
                ls=StringSubstr(LotsProgression,i);
                k++;
                ArrayResize(TimeSet,k);
                TimeSet[k-1]=ls;
                break;
        }
   }
}

void OnTick() 
{
   MakeAllTime(Indi3_Day_Mo,Indi1DayMoArray);
   Alert(Indi1DayMoArray[1]);
}
qjol
3243
qjol  

there isn't OnTick in the old MT4

void OnStart() 

instead of

void OnTick() 

working just fine (i used a script)

Alain Verleyen
Moderator
32403
Alain Verleyen  
capilta:

Dear Guys,

Below code not work with new build. but it work on old MQL. in Alert Indi1DayMoArray[1] show nothing. but it should be show "08:00:59"

08:00:59 is shown. Code as provided, build 610.

2014.02.18 11:28:52.473 _testing_ EURUSD,M1: Alert: 08:00:59

I suggest you to initialize all your variables (mainly i and k aren't initialized in your code), see documentation :

Any variable can be initialized during definition. If a variable is not initialized explicitly, the value stored in this variable can be any. Implicit initialization is not used.
To add comments, please log in or register