MetaTrader 4 Build 529 beta released with new compiler - page 39

 
Out of range unambiguously indicates an error in the code - going outside the array. The string and error location are indicated there, so look for the error.
 

Here's the code.


datetime   prevtime0 = 0;
double prevVolume0 =0;
double prevClose0 =0;
void init()
{
   Print("_______Test init");
   prevtime0 = iTime(NULL,PERIOD_M1,0); 
   prevVolume0 = iVolume(NULL,PERIOD_M1,0);
   prevClose0 = iClose(NULL,PERIOD_M1,0);
}

void start()
{
  Print(" prevtime0!!!!! = ",prevtime0," iTime(NULL,PERIOD_M1,0) =",iTime(NULL,PERIOD_M1,0) );
  Print(" prevVolume0!!!!! = ",prevVolume0," iVolume(NULL,PERIOD_M1,0) =",iVolume(NULL,PERIOD_M1,0) );
  Print(" prevClose0!!!!! = ",prevClose0," iClose(NULL,PERIOD_M1,0) =",iClose(NULL,PERIOD_M1,0) );
  Print("");

  prevtime0 = iTime(NULL,PERIOD_M1,0); 
  prevVolume0 = iVolume(NULL,PERIOD_M1,0);
  prevClose0 = iClose(NULL,PERIOD_M1,0);

}

Here is the result of execution in terminal Version 4.0 Build 536

2013.11.11 22:53:08 Test EURJPY,M1: prevClose0!!!!! = 133.02 iClose(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:53:08 Test EURJPY,M1: prevVolume0!!!!! = 133.02 iVolume(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:53:08 Test EURJPY,M1: prevtime0!!!!! = 2013.11.11 22:38:00 iTime(NULL,PERIOD_M1,0) =2013.11.11 22:38:00
2013.11.11 22:52:25 Test EURJPY,M1:
2013.11.11 22:52:25 Test EURJPY,M1: prevClose0!!!!! = 133.02 iClose(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:52:25 Test EURJPY,M1: prevVolume0!!!!! = 133.02 iVolume(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:52:25 Test EURJPY,M1: prevtime0!!!!! =2013.11.11 22:38:00 iTime(NULL,PERIOD_M1,0) =2013.11.11 22:38:00

As you can see neither iClose, nor iVolume, nor iTime changes.

I assume so, and so do the other functions that start with i.

Also, the iVolume function in this example shows clearly not Volume.

At the same time in the tester, everything works and changes except iVolume. It doesn't work there either.

Note.

 
thecore:

Here's the code.


Here is the result of execution in terminal Version 4.0 Build 536

2013.11.11 22:53:08 Test EURJPY,M1: prevClose0!!!!! =133.02 iClose(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:53:08 Test EURJPY,M1: prevVolume0!!!!! =133.02 iVolume(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:53:08 Test EURJPY,M1: prevtime0!!!!! =2013.11.11 22:38:00 iTime(NULL,PERIOD_M1,0) =2013.11.11 22:38:00
2013.11.11 22:52:25 Test EURJPY,M1:
2013.11.11 22:52:25 Test EURJPY,M1: prevClose0!!!!! =133.02 iClose(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:52:25 Test EURJPY,M1: prevVolume0!!!!! =133.02 iVolume(NULL,PERIOD_M1,0) =133.02
2013.11.11 22:52:25 Test EURJPY,M1: prevtime0!!!!! =2013.11.11 22:38:00 iTime(NULL,PERIOD_M1,0) =2013.11.11 22:38:00

As you can see neither iClose, nor iVolume, nor iTime changes.

I assume that other functions which start with i do not change either.

Also, the iVolume function in this example clearly shows not Volume.

At the same time in the tester, everything works and changes except iVolume. It doesn't work there either.

Note.

Well, I did. What's wrong?
 
tara:
Well, I did. What's wrong?


Right...

The iTime(NULL,PERIOD_M1,0) function gives the wrong time from the terminal on the left.

Terminal gives 2013.11.11 22:53:08, iTime gives 2013.11.11 22:38:00, and should give

2013.11.11 22:53:00

iVolume(NULL,PERIOD_M1,0) should return some integer, for example 1, 2, 3, 100, not

as in this example 133.02

iClose should give out 133.02 in the first case, and 133.03 in the second.

 

All these functions work a little differently, on a minute-by-minute basis. Your printing works in ticks. Time in MT is counted in seconds.

And the second terminal, in general, on the left :)

 
tara:

All these functions work a little differently, on a minute-by-minute basis. Your printing works in ticks. Time in MT is counted in seconds.

And the second terminal, in general, on the left :)

Look, I understand that you have no one to talk to in the evening.

I know that the minutes, that's why in the printout of the result and showed SPECIAL

two results at different minutes.

And besides, this message was not for you, but for the developers.

 
thecore:

iVolume(NULL,PERIOD_M1,0) should return an integer, for example 1, 2, 3, 100, but not

as in this example 133.02

Looks like iVolume really does return the last price(closing price) instead of volume.

But I was quite amused by the description from the help (the first one is from the file, and the second one is taken from the website)

1

datetime  iVolume(
   string           symbol,          // символ
   int              timeframe,       // период
   int              shift            // сдвиг
   );

2

double iVolume(string symbol, int timeframe, int shift)
 
thecore:


Right...

The iTime(NULL,PERIOD_M1,0) function gives the wrong time from the terminal on the left.

Terminal shows 2013.11.11 22:53:08, iTime shows 2013.11.11 22:38:00 and should show

2013.11.11 22:53:00

iVolume(NULL,PERIOD_M1,0) should return some integer, for example 1, 2, 3, 100, not

as in this example 133.02

iClose should output 133.02 in the first case, and 133.03 in the second.


Try using RefreshRates(), OnTick has the same problem, time and prices are not updated in the tester, but when using RefreshRates() all is ok ...
 
Two more problems with the indicators, please see Service Desk!
 
thecore:

As you can see, neither iClose, nor iVolume, nor iTime changes.

I assume that neither do the other functions that start with i.

Also, the iVolume function in this example shows clearly not Volume.


Corrected. Thank you