
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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