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). |
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.
I know I may sound stupid but what is "hedging" in forex, sorry but nobody is a monopoly of knowledge.
Does it have a command to check if the account is hedge?
Thanks.
Or use my simpler version. Returns true or false.
{
ENUM_ACCOUNT_MARGIN_MODE res = (ENUM_ACCOUNT_MARGIN_MODE)AccountInfoInteger(ACCOUNT_MARGIN_MODE);
return(res==ACCOUNT_MARGIN_MODE_RETAIL_HEDGING);
}
Or use my simpler version. Returns true or false.
{
ENUM_ACCOUNT_MARGIN_MODE res = (ENUM_ACCOUNT_MARGIN_MODE)AccountInfoInteger(ACCOUNT_MARGIN_MODE);
return(res==ACCOUNT_MARGIN_MODE_RETAIL_HEDGING);
}
Thanks Pz !

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Does it have a command to check if the account is hedge?
Thanks.