Download MetaTrader 5

help calculating remaining margin

To add comments, please log in or register
Brendan
916
Brendan  
Hi,

im having trouble with something.
I want to calculate remaining free available Margin (Not as a % but in dollars)


double margin_level() {
   double value =0;
   if(AccountFreeMargin()>0) value = NormalizeDouble(AccountBalance()-AccountProfit()-AccountMargin(),2);
   return(value);

If my profit is minus, i cant get it to calculate the correct free margin figures.
My coding knowledge is very limited.
Thanks for your help.
Mohamad Zulhairi Baba
7716
Mohamad Zulhairi Baba  
Brendan:
Hi,

im having trouble with something.
I want to calculate remaining free available Margin (Not as a % but in dollars)


double margin_level() {
   double value =0;
   if(AccountFreeMargin()>0) value = NormalizeDouble(AccountBalance()-AccountProfit()-AccountMargin(),2);
   return(value);

If my profit is minus, i cant get it to calculate the correct free margin figures.
My coding knowledge is very limited.
Thanks for your help.

double FreeMargin()
{   
   double Margin = 0;
   
   if(AccountMargin()==0) Margin = AccountBalance();
   else Margin = AccountFreeMargin();
   
   return Margin;
}
Brendan
916
Brendan  
Mohamad Zulhairi Baba:


Hi and thank you!
To add comments, please log in or register