Update...
I tried to validate twice today. Still same errors.
I still do not understand when Required margin is not available for a given trade EA should say that "Not enough money for the trade". Isn't it normal ? If so then why automatic validator is holding there?
I am so stuck. I will be really grateful if someone can point me out towards some direction.
Thanks in advance.
if(required_margin>free_margin) { //--- report the error and return false //Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError()); return(false); }
The print statement is commented out.
Your customer most likely wants to look in the log to see what happened.The print statement is commented out.
Your customer most likely wants to look in the log to see what happened.If you have read my whole story then you would notice that I commented it out to see if the log file size exceeds problem occurs or not. After commenting it out the Log file size exceed problem did not show up anymore but then error was No trade operation. The automatic validator is testing with 100 lot size against a deposit of 100000 and EA is printing Not enough money continuously which causes the log file size to exceed. I hope you now understood my problem.
I can't see any code that deals with position sizing in your examples.
My position sizing function is similar the one that is found on the Moving Average EA that comes with MT5 downlaod. Please note that I am trying to update 4th version of my product. Since I have not made any changes to the position sizing then there should be no problem with the existing position sizing function.
Update...I am still stuck on this.
Heres the code for my last attempt.
//+------------------------------------------------------------------+ //| Check margin | //+------------------------------------------------------------------+ bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type) { //--- Getting the opening price MqlTick mqltick; SymbolInfoTick(symb,mqltick); double price=mqltick.ask; if(type==ORDER_TYPE_SELL) price=mqltick.bid; //--- values of the required and free margin double required_margin=RoboAccountInfo.MarginCheck(symb,type,lots,price); double free_margin=RoboAccountInfo.FreeMargin(); //--- call of the checking function //--- if there are insufficient funds to perform the operation if(required_margin>free_margin) { //--- report the error and return false Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError()); return(false); } //--- checking successful return(true); } //+------------------------------------------------------------------+ //| Optimize lot sizes when UseAutoLot true | //+------------------------------------------------------------------+ double lotSize(void){ double price=0.0; double margin=0.0; //--- select lot size if(!SymbolInfoDouble(_Symbol,SYMBOL_ASK,price)) return(0.0); if(!OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,1.0,price,margin)) return(0.0); if(margin<=0.0) return(0.0); double lot=NormalizeDouble(AccountInfoDouble(ACCOUNT_MARGIN_FREE)*AutoLotRisks/margin,2); //--- calculate number of losses orders without a break if(LotDecreaseFactorIfLossOccurs>0) { //--- select history for access HistorySelect(0,TimeCurrent()); //--- int orders=HistoryDealsTotal(); // total history deals // number of losses orders without a break for(int i=orders-1;i>=0;i--) { ulong ticket=HistoryDealGetTicket(i); if(ticket==0) { Print("HistoryDealGetTicket failed, no trade history"); break; } //--- check symbol if(HistoryDealGetString(ticket,DEAL_SYMBOL)!=_Symbol) continue; //--- check profit double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT); if(profit>0.0) break; if(profit<0.0) losses++; } numoflosses=losses; //--- if(losses>1) lot=NormalizeDouble(lot-lot*losses/LotDecreaseFactorIfLossOccurs,1); } //--- normalize and check limits double stepvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP); lot=stepvol*NormalizeDouble(lot/stepvol,0); double minvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN); if(lot<minvol) lot=minvol; double maxvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX); if(lot>maxvol) lot=maxvol; //--- return trading volume return(lot); }
Inside OnTick() I am checking CheckMoneyForTrade() before placing trade. Its working perfectly in my strategy tester and also in demo trading. I dont understand why the Automatic Validator is trying to place order with lot sizes that is more than the free margin. This is causing the Print command in CheckMoneyForTrade() to be printed continuously until the log file size exceeds. This same code has been validated in previous versions.
I am surprised none can figured it out yet. I really need this to get done as one of client is waiting for this update. If you do not understand my problem then let me know I will explain it more.
I am also stuck.
My MT5 EA unable to pass the validation anymore. With CheckMoneyForTrade() function, EA validation fails with the error "there are no trading operations" and without CheckMoneyForTrade(), validation fails due to the error "not enough money...."
Just for the purpose of testing, I coded a function to open a buy trade on every new bar still the validation is getting failed with "there are no trading operations". The same EA is opening trades perfectly when tested on MT5 with Metaquotes demo account server.
I am also stuck.
My MT5 EA unable to pass the validation anymore. With CheckMoneyForTrade() function, EA validation fails with the error "there are no trading operations" and without CheckMoneyForTrade(), validation fails due to the error "not enough money...."
Just for the purpose of testing, I coded a function to open a buy trade on every new bar still the validation is getting failed with "there are no trading operations". The same EA is opening trades perfectly when tested on MT5 with Metaquotes demo account server.
I have been stuck with this almost a week. Same problem. I think the problem is with the Automatic Validator's logic. Its not using the lot sizes that EA decides rather its directly testing how EA behaves with lot sizes more than free margins.
I have been stuck with this almost a week. Same problem. I think the problem is with the Automatic Validator's logic. Its not using the lot sizes that EA decides rather its directly testing how EA behaves with lot sizes more than free margins.
Yes. The validator always used to stress test using bigger lot sizes and negative margin but I think it is not using the normal lot sizes anywhere in the tests thats why we are getting the error "there are no trading operations".
- 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 been thinking about to to create a thread where EA Developers/Sellers can discuss and share similar errors and their possible solution on a daily basis. Because the automatic product validation software itself gets updated like all software does, possibilities for occurring new validation errors is more likely high. We can make this place as an one stop place where EA Sellers/Developers can point out newly identified errors and get quick responses or find quick solutions as well as attract the attention of Automatic Product Validation Developers/Moderators easily.
Before uploading for Automatic Product Validation make sure your EA complies the To Do's mentioned
here: https://www.mql5.com/en/articles/2555
and here: https://www.mql5.com/en/blogs/post/686716
Here comes the errors that I am facing today...
I have been trying to upload a new version of my product for couple of days but failing every time. When I tried to upload first time then Automatic Validation failed with errors "There are no trading operations". I noticed it tried to trade with 100 lots on EURUSD, GBPUSD and XAUUSD. The error is like this:
In order to improve the situation i modified my EA where it check required margin inside OnTick() from this:
To this global function which is :
After checking this function on every places where my EA tries to submit trades I realize the "Not Enough Money" error was not there anymore but then it started to show new error which is Log File Size Exceeded
At this point I suspect that the log was probably getting filled out with the Print command from CheckMoneyForTrade() function. So I decided to take off the print command and re-uploaded for validation with the modified CheckMoneyForTrade():
This time there was no Log file Exceed error but this error:
Now the question is why the Automatic Validator will try to trade with 100 lot against a deposit of 100000? Isn't it violating what the EA is supposed to do? My EA is is set to 0.01% risk when I uploaded for validation. So the Automatic Validator is trying to test beyond the EA parameters. However when my EA found required margin for 100 lot is not available then it prints Not enough money .. text from the CheckMoneyForTrade().
Isn't it how any EA supposed to work? If so then what is the point of stress testing with 100 lot size test and filling out the log files at the end?
In my local terminal demo trading and strategy tester is working just fine. I even tried to upload my older versions which was once succeeded with validation but not now. You guys know any work around?
BR
Syed