question about symbol expiration type

 

hello

Im a liitle bit confused about this. I donkt know how to explain it.

Im trying to get information about Symbol. here is my script.

void OnStart() {

   int expirationMode = SymbolInfoInteger(_Symbol, SYMBOL_EXPIRATION_MODE);

   Print("expirationMode is: " + (string)expirationMode );
}

output:
expirationMode is: 15

what does this 15 mean?

here in this link it says that the return value should be 1 or 2 or 4 or 8

Im confused
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
farhadmax: what does this 15 mean?


here in this link it says that the return value should be 1 or 2 or 4 or 8

It's a bit map. 15 means 1 or 2 or 4 or 8. (SII(mode) & SYMBOL_EXPIRATION_XXX) != 0 Means XXX allowed.

 

Here is a code from mql5 website


//+------------------------------------------------------------------+
//| Checks if the specified expiration mode is allowed               |
//+------------------------------------------------------------------+
bool IsExpirationTypeAllowed(string symbol,int exp_type)
  {
//--- Obtain the value of the property that describes allowed expiration modes
   int expiration=(int)SymbolInfoInteger(symbol,SYMBOL_EXPIRATION_MODE);
//--- Return true, if mode exp_type is allowed
   return((expiration&exp_type)==exp_type);
  }

 i dont understand this part of the code :

return((expiration&exp_type)==exp_type);


could you explain it a little bit? what does that & do?

 
farhadmax # i dont understand this part of the code :
return((expiration&exp_type)==exp_type);

Expiration & exp_type isolates that bit; the result is zero or that bit. If the result is zero, the expression is false otherwise true. Return the result.

Simplified.
True is non-zero.
return expiration & exp_type;
Reason: