it says Error = 4753 which means position not found.
When I use
it still gives the same error.
I tried the Print statement that you added in, and for some reason it returns the error when it is placed where you have it in the code when the code itself otherwise works, but it is in the true statement, so when it's executed, it might be trying to find an error because it has been called to do so, but i don't know for sure. However, put the Print statement by itself like this
if(PositionSelect(Symbol())==false)
Print(" Position select = ", GetLastError());
That way it only looks for an error if the position couldn't be selected. This worked for me when i tried it. Something else you should have for the code is an if statement like this
if(PositionsTotal()>0)
{
//trailingstop code goes here
}
The statement makes sure that there are positions to be selected before the code is run. I hope all of this helps.
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
How to use this code for stocks? I saw all trail stop ea includes NomalizeDouble. For stocks, price close is integer and for example price step is 25. Close like 1000 1025 1050 1075.
Lot size must also be adjusted to a multiple of LotStep and check against
min and max. If that is not a power of 1/10 then
NormalizeDouble is wrong. Do it
right.
Nice. Looks good to me everything but
when I run this code
it says Error = 4753 which means position not found.
When I use
it still gives the same error.
I tried the Print statement that you added in, and for some reason it returns the error when it is placed where you have it in the code when the code itself otherwise works, but it is in the true statement, so when it's executed, it might be trying to find an error because it has been called to do so, but i don't know for sure. However, put the Print statement by itself like this
That way it only looks for an error if the position couldn't be selected. This worked for me when i tried it. Something else you should have for the code is an if statement like this
The statement makes sure that there are positions to be selected before the code is run. I hope all of this helps.
if(PositionsTotal()>0){
}
Looks like working.
Thanks you, guys, for your kind help.
Hello,
How to use this code for stocks? I saw all trail stop ea includes NomalizeDouble. For stocks, price close is integer and for example price step is 25. Close like 1000 1025 1050 1075.
thanks.