Download MetaTrader 5

Check if account is hedge

To add comments, please log in or register
Pablo Rego
1742
Pablo Rego  

Does it have a command to check if the account is hedge?

Thanks. 

Vladimir Karputov
Moderator
58804
Vladimir Karputov  
Pablo Rego:

Does it have a command to check if the account is hedge?

Thanks. 

You need to get a property of enumeration ENUM_ACCOUNT_MARGIN_MODE:

ENUM_ACCOUNT_MARGIN_MODE

Identifier

Description

ACCOUNT_MARGIN_MODE_RETAIL_NETTING

Used for the OTC markets to interpret positions in the "netting" mode (only one position can exist for one symbol). The margin is calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE).

ACCOUNT_MARGIN_MODE_EXCHANGE

Used for the exchange markets. Margin is calculated based on the discounts specified in symbol settings. Discounts are set by the broker, but not less than the values set by the exchange.

ACCOUNT_MARGIN_MODE_RETAIL_HEDGING

Used for the exchange markets where individual positions are possible (hedging, multiple positions can exist for one symbol). The margin is calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE) taking into account the hedged margin (SYMBOL_MARGIN_HEDGED).

Jose Francisco Casado Fernandez
3146
Jose Francisco Casado Fernandez  
Pablo Rego:

Does it have a command to check if the account is hedge?

Thanks. 

You can use this simple script:

//+------------------------------------------------------------------+
//|                                                  Margin Mode.mq5 |
//|                                                       Robertomar |
//|         http://www.tradingunited.es/foro/members/robertomar.html |
//|                                                robertoma@ono.com |
//|                                       robertomartrader@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Robertomar"
#property link      "http://www.tradingunited.es/foro/members/robertomar.html"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
    ENUM_ACCOUNT_MARGIN_MODE margin_mode;
    string hedge = IsHedging(margin_mode) ? "allowed" : "not allowed";
    
    PrintFormat("Margin Mode: %s.  Hedging %s", EnumToString(margin_mode), hedge);
  
  }
  
//+------------------------------------------------------------------+

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

}

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



Regards.

Files:
Nkechi Sonia Kanu
285
Nkechi Sonia Kanu  
I know I may sound stupid but what is "hedging" in forex, sorry but nobody is a monopoly of knowledge.
Jose Francisco Casado Fernandez
3146
Jose Francisco Casado Fernandez  
Kanu Nkechi Sonia:
I know I may sound stupid but what is "hedging" in forex, sorry but nobody is a monopoly of knowledge.
It means the possibility to open several positions on a same symbol, including opposite positions. It was not possible previously in MT5, but now it's possible. Regards.
To add comments, please log in or register