date time

 

My code is the following ... 

datetime a;
//+----------------------------------
int OnInit()
  {
//---
   a=Period();
   Comment(a);
//---
   return(INIT_SUCCEEDED);
  }
/*
result=
1970.01.01 04.33.28
16408 sec past of 1970.01.01 00.00.00
if a declared as int, result=16408
*/

chart time frame is D1.

whats happening?

when did 16408 start?

what return Period() function

i think Period() function returned timeframe of the current chart.(for this=D1)

thanks lot

Documentation on MQL5: MQL5 programs / Runtime Errors
Documentation on MQL5: MQL5 programs / Runtime Errors
  • www.mql5.com
The executing subsystem of the client terminal has an opportunity to save the error code in case it occurs during a MQL5 program run. There is a predefined variable _LastError for each executable MQL5 program. Before starting the OnInit function, the _LastError variable is reset...
 
troojansafir:

My code is the following ... 

chart time frame is D1.

whats happening?

when did 16408 start?

what return Period() function

i think Period() function returned timeframe of the current chart.(for this=D1)

thanks lot

Period() is an enumeration  try the code below and you will see.

If you want the physical period duration try using PeriodSeconds()

  
   Print("Period is: " + EnumToString(Period()));
   Print("Period Seconds are: " + PeriodSeconds());

// RESULTS
//	Period is: PERIOD_M5
//	Period Seconds are: 300
 
tnx lot
 
string   as_string(ENUM_TIMEFRAMES period){
   if(period == PERIOD_CURRENT)  period   = (ENUM_TIMEFRAMES) _Period;
   string   period_xxx  = EnumToString(period);                // PERIOD_XXX
   return StringSubstr(period_xxx, 7);                         // XXX
}
Reason: