- www.mql5.com
See too:
Forum on trading, automated trading systems and testing trading strategies
Desperate "No trading operations" error
Vinicius Pereira De Oliveira, 2024.04.21 14:42
It must be corrected, Juan. For example: if the EA uses a fixed volume parameter and by default this volume is set at 0.01, but during validation testing the tested symbols do not allow volume 0.01, then the EA does not open a position and will not be able to be published. So, to avoid this problem, you can use a function like the following, in addition to the volume checks recommended in the article:
//+--------------------------------------------------------------------------------------------------------------------+ //| This function normalizes the volume according to the minimum volume change step | //+--------------------------------------------------------------------------------------------------------------------+ double NormalizeVolume(double Lot) { ResetLastError(); //--- Minimal and maximal allowed volume for trade operations double LotMin = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); double LotMax = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); //--- Get minimal step of volume changing double LotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); //--- Check if an execution error occurred if(GetLastError() != ERR_SUCCESS) { return(WRONG_VALUE); } //--- Normalizes the volume Lot = LotMin + MathFloor((Lot - LotMin) / LotStep) * LotStep; Lot = NormalizeDouble(MathMin(LotMax, MathMax(LotMin, Lot)), 2); //--- Normalized volume return(Lot); }
Hi
For publication the EA has to pass more strict requirements (as mentioned above) – you need to normalize volumes and check if trades are possible to placed (enough funds etc) for more extreme conditions than your mq5 tests (for example very small account balance). So use some functions like normalize volume (mentioned above) and something like:
bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type, double op = 0) { ResetLastError(); //--- Getting the opening price MqlTick mqltick; SymbolInfoTick(symb,mqltick); double price=op; if(price==0){ price = mqltick.ask; if(type==ORDER_TYPE_SELL || type==ORDER_TYPE_SELL_STOP || type==ORDER_TYPE_SELL_LIMIT){ price=mqltick.bid; } } type = (ENUM_ORDER_TYPE)MathMod(type, 2); //Print(price+" "+EnumToString(type)+" "+lots); //--- values of the required and free margin double margin,free_margin=AccountInfoDouble(ACCOUNT_MARGIN_FREE); //--- call of the checking function if(!OrderCalcMargin(type,symb,lots,price,margin)) { //--- something went wrong, report and return false Print("Error in ",__FUNCTION__," code=",GetLastError()); return(false); } //--- if there are insufficient funds to perform the operation if(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);
Have a nice weekend
So if I understand correctly, I cannot use a fixed lot size? For example, 0.01, because it's too small, but at the same time, I can't use a larger lot size (0.05) because it tests situations where there are insufficient funds in the account. Therefore, I must create a "flexible" lot size that adjusts dynamically?
Do I understand this correctly?
So if I understand correctly, I cannot use a fixed lot size? For example, 0.01, because it's too small, but at the same time, I can't use a larger lot size (0.05) because it tests situations where there are insufficient funds in the account. Therefore, I must create a "flexible" lot size that adjusts dynamically?
Do I understand this correctly?
No, that's not quite it... We are talking about two checks (among many others) that must be carried out by your EA to pass automatic validation: normalization and volume verification (to correct the current error) and sufficiency check of funds to trade... Let's go from the beginning:
1. The article suggested by Yashar presents, with examples, the tests that the EA must pass during automatic validation for publication on the Market, among which I highlight:
- Insufficient funds to perform trade operation
- Invalid volumes in trade operations
- Limiting Number of Pending Orders
- Limiting Number of Lots by a Specific Symbol
- Setting the TakeProfit and StopLoss levels within the SYMBOL_TRADE_STOPS_LEVEL minimum level
- Attempt to modify order or position within the SYMBOL_TRADE_FREEZE_LEVEL freeze level
2. You can see that the first test highlighted above is checking the sufficiency of funds to trade, which is what Marzena commented on.
3. The second test highlighted is the validity of the volume of operations (which is precisely where your EA is currently showing an error). In the article, the CheckVolumeValue() function is presented, however, this function only returns whether the volume is valid or not, but does not correct for the proper volume. Therefore, I suggested above using the NormalizeVolume() function to make this correction (before checking), if necessary, understand? For example, if your EA uses a fixed lot of 0.05 in the input parameters by default, but during automatic validation the minimum lot of the tested symbol is 0.10, if normalization was not performed, an invalid volume error will occur when opening a position, but if the NormalizeVolume() function is used, the minimum symbol lot (0.10) will be used when sending the order.
4. See too:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am creating my own expert advisor, but unfortunately, I keep encountering the same issue when trying to publish it on the website. However, when I run a test on MT5, I get no errors, and I have even tried different currency pairs and a 5-year chart period... but still, no errors occur. I only encounter this error when trying to publish on the market. I have even gone through all the points of 'Why products are checked before they are published in the Market,' based on which I added more conditions to the code to eliminate all errors. Unfortunately, I still keep encountering them. Has anyone had a similar experience?