mql coding help

 

Hi,

Why this code draws vlines only on history in MT4 tester?

I'd like to it worked on new data.

 

 void OnTick () {


for(int j=0; j<=100; j++) {

for(int i=0; i<=10; i++) {

if (Close[i+1]>Open[i+1]) 

ObjectCreate(0,"pionowa"+"_"+i+"_", OBJ_VLINE, 0, Time[i+1], 0);
continue;

}

}


}
 

The code doesn't really make much sense.

What is the "j" loop doing?

The continue statement is unnecessary. 

After the first run of your "i" loop, the objects have been created. On the subsequent runs, you will be trying to create an object that already exists.

Checking your return codes from ObjectCreate would have helped you.

 
adka:

Hi,

Why this code draws vlines only on history in MT4 tester?

I'd like to it worked on new data.

 

 void OnTick () {


for(int j=0; j<=100; j++) {

for(int i=0; i<=10; i++) {

if (Close[i+1]>Open[i+1]

ObjectCreate(0,"pionowa"+"_"+i+"_", OBJ_VLINE, 0, Time[i+1], 0);
continue;

}

}


}
You should then use new data and not history.
Reason: