I also tried to use this function but I still had no trade operation error.
double NormalizeVolume1(double pVolume) { double volume = 0; double volMin = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN); double volMax = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX); double volStp = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP); if(pVolume > 0) { if(pVolume < volMin) volume = volMin; volume = MathRound(volume / volStp) * volStp; // Notice how "volume" is the correct first operand of MathRound and not "pVolume" if(pVolume > volMax) volume = volMax; // Again, notice how "volume" is the correct second operand of MathMin and not "pVolume" } else volume = volMin; return(volume); };
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I am trying to publish my EA and am getting a no trade operation error. If I take this following code out
then trade operation occurs but I get an error of invalid volume.
The EA is fully functional on my terminal.
Any suggestion?