help calculating remaining margin

 
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.
 
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;
}
 
Mohamad Zulhairi Baba:


Hi and thank you!
Reason: