_Period above M30 causes problems

 

Hello all,

can somebody tell me why this small script returns totally wrong numbers when applying it on a timeframe > M30?

void OnStart()
  {
   Alert((string)_Period);
  }
 
Marcus Riemenschneider:

Hello all,

can somebody tell me why this small script returns totally wrong numbers when applying it on a timeframe > M30?

There is no wrong value, but a wrong usage.

Try :

Alert(EnumToString(Period()));
 
Checkup / Period - Reference on algorithmic/automated trading language for MetaTrader 5
Period - Checkup - MQL4 Reference

Period

Returns the current chart timeframe.

ENUM_TIMEFRAMES  Period();

Period

Returns the current chart timeframe.

int  Period();

 
whroeder1:
Checkup / Period - Reference on algorithmic/automated trading language for MetaTrader 5
Period - Checkup - MQL4 Reference

Period

Returns the current chart timeframe.

ENUM_TIMEFRAMES  Period();

Period

Returns the current chart timeframe.

int  Period();


Thanks guys... moving from MQL4 to MQL5 can really be very painful...
Reason: