Account Margin

 

Hello guys!

Kndly advice on the below:

 ENUM_ACCOUNT_STOPOUT_MODE stopoutmode=(ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE);
  double margin_call  = AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL);
   Print(StringFormat("StopOut Mode =%.2s\n",EnumToString(stopoutmode)));
   Print( StringFormat("Call Level =%.2f\n",margin_call));
   /*
   The result will be 
   StopOut Mode = AC
   Call Level = 100
   
   */

I suppose Stopout mode will be percent. But I dont understand  about ACCOUNT_MARGIN_SO_CALL. If stopmode will be percent, then margin call will be also percent, but from what? I belive that this result I get of " 100" is percentage, but do not understand from what it is . Thanks !!

 

From the documentation:

In case equity is not enough for maintaining open orders, the Stop Out situation, i.e. forced closing occurs. The minimum margin level at which Stop Out occurs can be set in percentage or in monetary terms. To find out the mode set for the account use the ENUM_ACCOUNT_STOPOUT_MODE enumeration.

ENUM_ACCOUNT_STOPOUT_MODE

Identifier

Description

ACCOUNT_STOPOUT_MODE_PERCENT

Account stop out mode in percents

ACCOUNT_STOPOUT_MODE_MONEY

Account stop out mode in money


"stopoutmode" variable in your code describes what is in the "margin_call" variable - percent or money amount.

BTW - you shortened EnumToString by using format "%.2s" - remove ".2"

Account Properties - Environment State - Constants, Enumerations and Structures - MQL4 Reference
Account Properties - Environment State - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Account Properties - Environment State - Constants, Enumerations and Structures - MQL4 Reference
 
Drazen Penic #:

From the documentation:


"stopoutmode" variable in your code describes what is in the "margin_call" variable - percent or money amount.

BTW - you shortened EnumToString by using format "%.2s" - remove ".2"

Thank you..but still....percent of what? call_level is 100 in my case, so it is 100% of what? Thank you

 
Daniel Cioca #:

Thank you..but still....percent of what? call_level is 100 in my case, so it is 100% of what? Thank you


For percent it should be a margin level. 

AccountEquity() / AccountMargin() * 100.0

That's the number you see as percentage on the bottom of the terminal window



There should be a margin call when margin level drops below percent or amount that is returned when you read ACCOUNT_MARGIN_SO_CALL.