Is this the proper way to check if an account is a hedging account?

 

Hello folks,

I want my EA to only run on hedging accounts. Is this the right way to check it?

// check if the account is a hedging account
if (AccountInfoInteger(ACCOUNT_MARGIN_MODE) != ACCOUNT_MARGIN_MODE_RETAIL_HEDGING) {
    Print("This is not a hedging account. This EA can only be run on hedging accounts!");
    return (INIT_FAILED);
}

Thank you very much in advance.

Greetings

Chris

 

Yes, it's all right.  Also, you can use a separate function like this:

int OnInit()
  {
    if (!IsHedging) {
    Print("This is not a hedging account. This EA can only be run on hedging accounts!");
    return (INIT_FAILED);
    }
    
    return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+

bool IsHedging() 
{ 
  
  ENUM_ACCOUNT_MARGIN_MODE  margmod = (ENUM_ACCOUNT_MARGIN_MODE)AccountInfoInteger(ACCOUNT_MARGIN_MODE);
  return(margmod==ACCOUNT_MARGIN_MODE_RETAIL_HEDGING); 

}

//+------------------------------------------------------------------+
 
Jose Francisco Casado Fernandez:

Yes, it's all right.  Also, you can use a separate function like this:


Thanks for the answer, just wanted to make sure I was doing it the right way.

Reason: