Converting PERIOD to numbers and working with 2 periods in one EA - page 2

 
Aldo Villella:

If you have a time frame current

and you want to get another multiple timeframe, you can only do it with string conversion:



uint second;

string val_seconds;

// Example

// current period PERIOD_M5

// second period PERIOD_M30


if (seconds == 300) // PERIOD_M5

last_period = PERIOD_M30;

val_seconds = EnumToString (PERIOD_M30);


You can not convert val_seconds to int because

ENUM_TIMEFRAME can only convert for long whole lengths

2E + 14 (16384


int PeriodEnumToMinutes(ENUM_TIMEFRAMES period = PERIOD_CURRENT)
{
   period = period==PERIOD_CURRENT?(ENUM_TIMEFRAMES)Period():period;
   return PeriodSeconds(period)/60;
}
Reason: