Error Code "NOT ENOUGH MONEY"
-
Hello support and team... an ea developed using this tool display error code "NOT ENOUGH MONEY" during validation phase on the mql5 portal. And l took a look at the reason and fixes here below is the recommendation "
test on EURUSD,H1
strategy tester report 67 total trades
test on NZDUSD,H1
2022.02.01 09:37:58 Tester: not enough moneyRecommended Fixes;
MQL4bool CheckMoneyForTrade(string symb, double lots,int type)
{
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);
}But l don't understand what to do... Please l need help.
-
This is an issue for a real programmer. Are you sure you are using the lot size limits as per mql5 site?
-
@YOUUNMEE It happens when there is not enough margin to open a new position. A few years ago I set up this way to check the margin. This is valid on forex pairs (no indices, no metal...ecc..)
Put these blocks just above your buy/sell market/pending orders and below your condition to trigger trades
I think someone here can write a few code lines to include all instruments
-
@ambrogio... Wow. you the best... Thank you so much the block worked.. and am really grateful.. Thank you
-
@YOUUNMEE you're welcome!