Download MetaTrader 5

SeriesInfoInteger and different results

To add comments, please log in or register
Write your articles using our editor. It is convenient!
kemalturgay
265
kemalturgay 2014.11.12 22:46 

I'm getting different results with the following code:

int OnInit()
  {
//--- indicator buffers mapping
   Print((datetime)SeriesInfoInteger("NZDUSD",PERIOD_H3,SERIES_SERVER_FIRSTDATE));
   Print((datetime)SeriesInfoInteger("NZDUSD",PERIOD_H3,SERIES_TERMINAL_FIRSTDATE));
   Print((bool)SeriesInfoInteger("NZDUSD",PERIOD_H3,SERIES_SYNCHRONIZED));
//---
   return(INIT_SUCCEEDED);
  }

And my results for starting it two times:



The result of the code is always changing for different runs as shown above without any change in the code.

I've never opened a chart for NZDUSD, so the second run is true ... but I don't know why I'm getting the result of 1970s sometimes.


And, as a second question, what is the SERIES_SYNCHRONIZED parameter?

Is it a flag for synchronized historical data between the terminal and the server?

If so, I think that it is working a little bit strangely - false when they are same and true when they are different as seen on the picture.

Maybe I'm wrong.


Any help about these issues?

Thanks.

Enrico Lambino
4323
Enrico Lambino 2014.11.13 12:16  
kemalturgay:

Any help about these issues?

Thanks.

About SERIES_SYNCHRONIZED, yes, I think you're right. I found the answer here: https://www.mql5.com/en/docs/series/timeseries_access#synchronized

About the return values, I remember being into this kind of problem before. It is better to use the second variant of the function (bool return value). If the first function variant did not get the data, it would just return zero (false). For datetime type, the return date is from 1970, since it uses unix time (1 January 1970 is the zero value).

For requested properties that are boolean, I think using the second function variant is necessary, as you will never know if you really got the you asked for, or it simply failed to get the value.

Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
  • www.mql5.com
Timeseries and Indicators Access / Organizing Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
kemalturgay
265
kemalturgay 2014.11.13 18:06  
Thanks a lot Iceron.
To add comments, please log in or register