[SOLVED] Again the dreaded "No trading operations" error - something wrong with the auto-validation?
A quick look, shows me that you have a "MaxSpread" parameter set to 1 pip.
So, what happens if the test is on a higher spread? ... Your EA will not trade — hence, "No trading operations".
Set a default for "MaxSpread" that disables it, or use a very high default for it.
EDIT: I did not check the rest of the code. There may be other reasons as well.
EDIT2: When asking about MT4 or MQL4, please post in that section (at the very end of the forum) and not in the other sections. Otherwise, you may end up receiving answers for MT5 or MQL5 instead.
A quick look, shows me that you have a "MaxSpread" parameter set to 1 pip.
So, what happens if the test is on a higher spread? ... Your EA will not trade — hence, "No trading operations".
Set a default for "MaxSpread" that disables it, or use a very high default for it.
EDIT: I did not check the rest of the code. There may be other reasons as well.
EDIT2: When asking about MT4 or MQL4, please post in that section (at the very end of the forum) and not in the other sections. Otherwise, you may end up receiving answers for MT5 or MQL5 instead.
Thanks for your advice. I didn't notice I was posting in the wrong forum.
Can a moderator please move this thread to the MT4 forum, or close it so that I can post it there?
Thanks.
OK, I finally passed the validation, and I'm gonna post here the solution in case it can help someone. The error was really stupid: with so many variables being passed to other functions, I was using the wrong parameter in the formula. Since the names were similar it was kind of hard to spot. I had to stop and debug everything line by line, and then boom! Really, the names were so similar I totally missed that - I should have known better. So here are my modifications:
1) In "RunChecksBeforeOrderSend", from...
double NormalizeVolume(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) { volume = MathMax(volMin, pVolume); volume = MathRound(pVolume / volStp) * volStp; volume = MathMin(volMax, pVolume); } else volume = volMin; return(volume); }
to...
double NormalizeVolume(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) { volume = MathMax(volMin, pVolume); volume = MathRound(volume / volStp) * volStp; // Notice how "volume" is the correct first operand of MathRound and not "pVolume" volume = MathMin(volMax, volume); // Again, notice how "volume" is the correct second operand of MathMin and not "pVolume" } else volume = volMin; return(volume); }
2) Finally, in "RequestOrderSend", when I call the checks before calling OrderSend, from...
// ORDERSEND CHECKS ResetLastError(); rc = RunChecksBeforeOrderSend(Symbol(), pType, pVolume);
to...
// ORDERSEND CHECKS ResetLastError(); rc = RunChecksBeforeOrderSend(Symbol(), pType, normVolume); // Notice how I use the just normalized volume "normVolume" instead of the original parameter "pVolume"
I hope this helps someone. Regards.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
EDIT #1: I've set the max spread allowed to 0.0 in the input settings following the recommendation of @Fernando Carreiro (thanks!). I've also added a function to close the trades I'm opening on every tick (I wasn't closing them before). Finally there was an issue in the "RunChecksBeforeOrderSend" block. I was always returning "GetLastError()" in some instances where there's no call to any internal function, and therefore I might be returning a previous "OK" when the logical operation was false - now I'm returning the raw error code. Still getting the validation error below. I'm very stuck with this.
EDIT #2: Problem solved - check comment #4.
EDIT #3: I can confirm that the error received by the validator is outdated, wrong and misleading. It won't probably be fixed, but from what I've gathered from other people and from this experience myself it's clear that the error has to do with the validity of the lot size and/or free margin available and not whether the EA can open trades in the currencies/timeframes in the message.Hello,
Another thread on this. I think I've read everything I could read about this issue, I've tried everything, and I'm still not able to get rid of the issue. There seems to be definitely something wrong with the auto-validation since a lot of people get the same error, which seems to have nothing to do with the issue at hand. Just as a reminder, tho I'm pretty sure by now you all know this error by heart...
First off, let me start by saying that my EA throws no error in the Strategy Tester nor in demo accounts nor in the two real accounts where it's actually running, at least with my current brokers. This said, I do understand that the auto-validation tries to test the EA on all possible challenging scenarios, and I've read all the checks that you're supposed to do. I believe I have, and I'm really hoping that someone proves me wrong so that I can correct the error.
From what I've been able to gather in the plethora of threads on this matter, it seems to be an issue related to not properly checking the free margin and/or the correctness of the lots. So, I started to strip off my EA of all bells and whistles, and I'm going bare-bones, sending a request to open a Buy and a Sell on every new bar. In the request:
I think I'm catching everything with the above, but I still get the same error, and I don't know what else to do. For the sake of clarity, I'm posting my bare-bones code here, just in case any of you guys is kind enough to take a look and tell me what I'm doing wrong. The main operations are done in the "RequestOrderSend" function, and note how before calling OrderSend I normalize the volume and price, and then proceed to run some checks in the "RunChecksBeforeOrderSend" function. Then and only then I call OrderSend.
Many thanks in advance for any hints!