bool CheckMoneyForTrade(string symb, double lots,int type) { if( AccountInfoDouble(ACCOUNT_FREEMARGIN) < 0 )return(false); double free_margin=AccountFreeMarginCheck(symb,type, lots); //-- if there is not enough money if(free_margin<0) { string oper=(type==OP_BUY)? "Buy":"Sell"; Print("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError()); return(false); } //--- checking successful return(true); }Sometimes without checking the balance. Returns this error.
bool CheckMoneyForTrade(string symb, double lots,int type)
{
if( AccountInfoDouble(ACCOUNT_FREEMARGIN) < 0 )(false);
double free_margin=AccountFreeMarginCheck(symb,type, lots);
//-- if there is not enough money
if(free_margin<0)
{
string oper=(type==OP_BUY)? "Buy":"Sell";
Print("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError());
return(false);
}
//--- checking successful
return(true);
}
Whats ACCOUNT_FREEMARGIN?
Whats with this (false)
after compile it says:
expression has no effect
Whats ACCOUNT_FREEMARGIN ?
Whats with this (false)
after compile it says:
expression has no effect
Has corrected. I skipped return =)
Has corrected. I skipped return =)
if( AccountInfoDouble(ACCOUNT_MARGIN_FREE) < 0 )return(false);
change it to this.but not working. also same as in my picture
if( AccountInfoDouble( ACCOUNT_MARGIN_FREE ) < 0 )return(false);
change it to this.but not working. also same as in my picture
ERR_NOT_ENOUGH_MONEY | 134 | Not enough money. |
Most likely still somewhere it is necessary to search for the reason.
but why it works on forex pairs and not on indices or metals

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
i have a question.
I have to do this
So i use that code from here https://www.mql5.com/en/articles/2555#not_enough_money
Than i call the function before OrderSend
so it is working well with forex symbols.
But when i use Gold or indices than it isnt working.
whats wrong here?? can someone help