Download MetaTrader 5

Please tell if I'm drunk!

To add comments, please log in or register
Karlis Balcers
7103
Karlis Balcers  

(Build 306)

int BarOfTheDay(datetime time)
{
   MqlDateTime dt;
   TimeToStruct(time, dt);
   int min = dt.min + (dt.hour * 60);
   Print("min = ", min, " dt.min = ", dt.min, " dt.hour = ", dt.hour );
   return min/Period();
}

Output:

  2010.08.16 20:07:36 K_sStatisticsOfBars (EURUSD,M30) min = 2008 dt.min = 0 dt.hour = 0

But if I do like this:

int BarOfTheDay(datetime time)
{
   MqlDateTime dt;
   TimeToStruct(time, dt);
   int min = dt.hour * 60;
   min += dt.min;
   Print("min = ", min, " dt.min = ", dt.min, " dt.hour = ", dt.hour );
   return min/Period();
}

 Then output is:

 2010.08.16 20:12:29 K_sStatisticsOfBars (EURUSD,M30) min = 0 dt.min = 0 dt.hour = 0


So, how is it??? Should I stop drinking? :)
Karlis Balcers
7103
Karlis Balcers  

More confused:

PERIOD_D1 = 16408 !!!!!

Was there any problems to give it a correct value as it was in MQL4 - 86400.

There is no warning in Help file or anything. Each developer needs to learn it in hard way by spending lot of time debugging and wondering why it's not working.

Karlis Balcers
7103
Karlis Balcers  

And of course - Period() returns some bullshit value too.

So, everyone, be aware  - ALWAYS USE PeriodSeconds() !

tektronic
137
tektronic  
tsaktuo:

(Build 306)

Output:

  2010.08.16 20:07:36 K_sStatisticsOfBars (EURUSD,M30) min = 2008 dt.min = 0 dt.hour = 0

But if I do like this:

 Then output is:

 2010.08.16 20:12:29 K_sStatisticsOfBars (EURUSD,M30) min = 0 dt.min = 0 dt.hour = 0


So, how is it??? Should I stop drinking? :)
You are not drunk for sure but jut try remember this is beta.  I am still waiting for 2 months now the major bugs to be solved but it appears I should go start drinking.. :)
To add comments, please log in or register