Check freemargin before Ordersend

To add comments, please log in or register
Raphael Schwietering
9031
Raphael Schwietering  

Hi,


how can i solve that i get Ordersend error 134. When i use strategy tester and acccount balance is 10dollar so i get ordersend error 134. But here the ea have to check money before ordersend.


So i have checked that with that function

bool CheckMoneyForTrade(string symb, double lots,int type)
  {  
   double free_margin=AccountFreeMarginCheck(symb,type, lots);
   //-- if there is not enough money
   if(free_margin<=0 || AccountInfoDouble(ACCOUNT_MARGIN_FREE) <=10)
     {
      string oper=(type==OP_BUY)? "Buy":"Sell";
      Print("Not enough money for ", oper," ",lots, " ", symb);
      return(false);
     }
   //--- checking successful
   return(true);
  }

and this i call before OrderSend

      if (!CheckMoneyForTrade(_Symbol,Entry_Amount,command)) return;//Check money for trade

But it works for Forex pairs but not for Indices and Gold. What can i do here.

To add comments, please log in or register