Closing trades for no reason
-
Hey Dreema!
Just finishing up my trader and it's having a huge issue thats preventing me from going live with it. Here are both versions:
- This one just makes a USDJPY trade while the global variable is toggled to a certain value. https://fxdreema.com/shared/rFjCPAzrc
- This one makes a trade based upon the opposite value. https://fxdreema.com/shared/D8lk8K8rb
Last Thursday during live testing it made 20+ trades (which makes sense) but what doesn't make sense is that from time to time it prematurely closes my trade. This trader only uses stop loss as a closing condition, so it's very concerning to me. I lost 33% of the account because of it! It will randomly close trades, which makes it hard to use the strategy I am using.
Is there a way you can take a look at it and suggest some alternate configurations to accomplish my goal and/or diagnose the issue I am having?
Thanks!
-$fX
-
You have trades closed by EA, not by SL or TP? This is interesting, because I can't see any block able to do that in these, and I don't think that is possible. The MQL4 function that closes trades "OrderClose()" exists in the code, but it can run only in when Virtual stops are used (when USE_VIRTUAL_STOPS is "yes"). You don't use Virtual stops, so I think that is something else.
Do you have another EA running in background, some that you forgot that is there and now it does some bad things?
-
That's what I was thinking!
I double checked whether or not virtual stops were on, and they were turned off. Is there a way I can just delete the whole virtual stops code snippet?
It just makes me worried since I intend to go live in a week. If you think of anything please let me know. Even if its just a failsafe that I can build in to turn off autotrading and shoot me an email that would work too. I just need some kind of possible event that would trigger it.
As always thanks for your time ;D
-
This function (and few more) is automatically added to all EAs, but you have at the very top:
if (USE_VIRTUAL_STOPS=="no") {return(0);}And USE_VIRTUAL_STOPS equals to no at the top of the EA, which means that it's forbidden to enter the body of the function. You can clear it's contents anyway, don't remove the function itself, as it is called from another functions.
But I think the problem is somewhere else. What are the logs saying?
-
I dont have access to the logs at the moment, but it didn't say anything in particular about the closes. I am going to leave it in demo for this week again and if I see anything it happening again I will send you screenshots and what was going on at the time. I will remove that variable from the final build and hope it helps.
You are right though it doesn't seem like the case. Here's hoping
