To be honest, I find your code confusing
Things like
double sTS=TrailingStop; double STS=sTS; if(STS<Min_Dist) STS=Min_Dist; // sTS is just an internmediary variable, not used elsewhere. So Why not double STS=TrailingStop; if(STS<Min_Dist) STS=Min_Dist;
Also it is better to use descriptive names for your variables, especially when you expect other people to read and understand your code
When I see STS later in the code, I have no idea what it is.
As for your problem, check the return/reasons why the OrderModify failed.
Initially the report would be that the modify failed and this would be repeated over and over because of being stuck in a while(true) loop
I guess that the trade hit either the original SL or TP, but the loop continues and then is trying to modify a ticket that has already closed. That is why you are getting the invalid ticket error.
Get rid of the while loop
To be honest, I find your code confusing
Things like
Also it is better to use descriptive names for your variables, especially when you expect other people to read and understand your code
When I see STS later in the code, I have no idea what it is.
As for your problem, check the return/reasons why the OrderModify failed.
Initially the report would be that the modify failed and this would be repeated over and over because of being stuck in a while(true) loop
I guess that the trade hit either the original SL or TP, but the loop continues and then is trying to modify a ticket that has already closed. That is why you are getting the invalid ticket error.
Get rid of the while loop
Thanks GumRai,
I will try all your suggestions and get back to you whether it solves the problem or not.
You are blessed
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Every Guru in the house,
Please I was working on a trailing stop code culled from the Mql4 book, the code is pasted below, I was to tweak it to move stop loss to break even level and also to start trailing after certain pips in profit is attained. It worked fine in doing those two things but after the price hits the trailing line to close the order, it starts and continues printing this message while it stops ea from opening further trades on the concerned currency pair: "unknown ticket 12345678 for OrderModify function", can somebody with good knowledge of coding than I review my code and tell me where I did it wrong?
Thanks in advance while waiting for assistance.