OrderClosePrice(), I have also tried it, that's why I don't use it
Fernando Carreiro:
Also, instead of using Bid or Ask for calculating the trailing stop, consider using the orders current closing price "OrderClosePrice()".
That way, you can combine the Buy and Sell logic into a single logic by using +ve or -ve to represent the direction in the calculations, making your code more robust without having to duplicate logic in reverse order for the two types.
Fernando Carreiro: One more thing, it might be best to use OrderOpenPrice() for the price value in OrderModify() for Market Orders. I have never tried it by using a price of "0.0", so it might fail. Not sure about it though.
First of all, you are not using any Print() command. So if u just check using if and return true or false, you'll never find the issue. Experienced developers may avoid it, but the beginners, mainly those who can't find his own mistake, must always use Print function.
Example:
if(condition)
{
Print(__FUNCTION__,", line ",__LINE__,", description of the event.");
returnfalse
}
DoSomething();
returntrue;
Then you have problems elsewhere. We cannot help you if don't provide a fully functioning code! So you will have to debug it yourself with the help of Print functions, just as suggested before and as in post #19 by @Samuel Manoel De Souza
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Also, instead of using Bid or Ask for calculating the trailing stop, consider using the orders current closing price "OrderClosePrice()".
That way, you can combine the Buy and Sell logic into a single logic by using +ve or -ve to represent the direction in the calculations, making your code more robust without having to duplicate logic in reverse order for the two types.
One more thing, it might be best to use OrderOpenPrice() for the price value in OrderModify() for Market Orders. I have never tried it by using a price of "0.0", so it might fail. Not sure about it though.
I have also tried it.
Then you are not using it correctly!
Not working says nothing! What is not working? Look in the logs for errors. Add some Prints to see where the logic is failing!
You keep saying you "tried" but you don't seem to know how to use things properly, so "tried" has no meaning here!
See the following code (untested as you haven't provided a complete code to test).
You keep saying you "tried" but you don't seem to know how to use things properly, so "tried" has no meaning here!
See the following code (untested as you haven't provided a complete code to test).
not working again!!!
not working again!!!
First of all, you are not using any Print() command. So if u just check using if and return true or false, you'll never find the issue. Experienced developers may avoid it, but the beginners, mainly those who can't find his own mistake, must always use Print function.
Example:
Try it and check the log again.
Then you have problems elsewhere. We cannot help you if don't provide a fully functioning code! So you will have to debug it yourself with the help of Print functions, just as suggested before and as in post #19 by @Samuel Manoel De Souza