enum interval // enumeration of named constants
{
month=1, // one-month interval
two_months, // two months
quarter, // three months - a quarter
halfyear=6, // half a year
year=12, // a year - 12 months
};
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- set the time interval equal to one month
interval period=month;
Print(EnumToString(period)+"="+IntegerToString(period));
//--- set the time interval equal to a quarter (three months)
period=quarter;
Print(EnumToString(period)+"="+IntegerToString(period));
//--- set the time interval equal to one year (12 months)
period=year;
Print(EnumToString(period)+"="+IntegerToString(period));
//--- check how the order type is shown
ENUM_ORDER_TYPE type=ORDER_TYPE_BUY;
Print(EnumToString(type)+"="+IntegerToString(type));
//--- check how incorrect values are shown
type=WRONG_VALUE;
Print(EnumToString(type)+"="+IntegerToString(type));
// Result:
// month=1
// quarter=3
// year=12
// ORDER_TYPE_BUY=0
// ENUM_ORDER_TYPE::-1=-1
}
|