- How to fix validation error for publishing EA
- OrderSend: Error code 131
- Please help me "OrderSend: Error code 131"
Forum on trading, automated trading systems and testing trading strategies
failed instant - Invalid volume
Vinicius Pereira De Oliveira, 2024.05.12 00:14
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:
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); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use