
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
Hi All,
Now I insert ticket and Lots in the OrderClose without using OrderTicket() and OrderLots() but it not closing the order too. Please help.
There are a couple of things you did wrong. I assume you want this EA to work on JPY pairs on M1 time frame. Do you want to place orders on new bar only and close orders on new bar only or do you want entry on new bar and exit if conditions are met? Here is what I think :
First you count orders with OrdersTotal().
Then calculate your variables
If there are orders in the market check if they have to be closed
If no orders in the market, check if entry conditions are met.
Let me know if you have any questions.
ticket is a local variable, so next tick, it will not have the same value
Put outside of the functions to make it Globalscope
total=OrdersTotal();
?????? ..... useless
check correctly what trades you have
look for right symbol and right magicnumber
with an orderloop you can then select the right trade to close with
.
with your method
you lose ticket value moment you restart your pc so
fails .....
Why did you quote my post and then not add a comment?
yes, it can close now. thank you GumRai. now i know ticket number keep on changing according to the ticks, so how to obtain the ticket number of the open order? I have to.use OrderTicket() right?
If you use OrderTicket() then just make sure you use OrderSelect() first and also make sure that it is the trade that you want to close.
yes, it can close now. thank you GumRai. now i know ticket number keep on changing according to the ticks, so how to obtain the ticket number of the open order? I have to.use OrderTicket() right?
Hi Chuale,
Here is an easy way to select your orders and close orders by symbol and by Magic number :
yes, it can close now. thank you GumRai. now i know ticket number keep on changing according to the ticks, so how to obtain the ticket number of the open order? I have to.use OrderTicket() right?
Hello again Chuale,
I was playing around with your idea on USDJPY and I couldn't get positive results without some changes.Here is a sample of my results on USDJPY on M1 chart :
Did you intend to use it on a different pair?
Exit on bar3 < -1 or bar3 > 1 didn't return positive results.
?????? ..... useless
check correctly what trades you have
look for right symbol and right magicnumber
with an orderloop you can then select the right trade to close with
.
with your method
you lose ticket value moment you restart your pc so
fails .....
If you mean that it isn't the best way to close an order I agree but if the guy doesn't want to use OrderSelect (or doesn't know how) and doesn't leave any open orders in the market it works.
We try to help each other here and your answer did not helped a bit, you didn't show him how to use Order Select function and his EA isn't working any better now due to your comment.
Next time you want to help, do it the right way, put the right code in there so others may actually learn something .
There are a couple of things you did wrong. I assume you want this EA to work on JPY pairs on M1 time frame. Do you want to place orders on new bar only and close orders on new bar only or do you want entry on new bar and exit if conditions are met? Here is what I think :
First you count orders with OrdersTotal().
Then calculate your variables
If there are orders in the market check if they have to be closed
If no orders in the market, check if entry conditions are met.
Let me know if you have any questions.