Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 842
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
OrderClose(OrderTicket(),0.01,Bid,2);
in "experts" it says "invalid ticket for OrderClose function".
Help? my goal is to close an order on the current chart.
Good evening! Help me understand the code below, sell is written on the same principle, why three options to open, because I had to fiddle with the option to avoid opening an order then - when the order opens on the current bar and closes on a no draw,
and the signal remains and opens again, so I have had to write it like this. The problem is that only one buy and sell order is opened and all else is silent. I cannot find any further errors. I am very grateful in advance.
How do you understand this line?
I do not know how to read this line and this one.
and this one...
Although this last line will work, but it is not so write ... I'm speechless.
Well, if you can't find the error, then there's probably no error...
OrderClose(OrderTicket(),0.01,Bid,2);
in "experts" it says "invalid ticket for OrderClose function".
Help? my goal is to close order on current chart.
What is the meaning of this line?
and this one.
And this one...
Although this last line will work, but that's not the way to write ... I'm speechless.
Well, if you didn't find the error, then there's probably no error...
1. If there are no open orders
2. If there are no closed orders.
What is wrong?
1. If there are no open orders
2. If there are no closed orders.
What is wrong?
int OrdersTotal(); - returns number, not truth-false, that's what's wrong. If there are no orders, it means 0. If there are orders, it's not only 1.
And there are no closed orders only on a freshly opened account that we haven't traded on yet. Again, this is an incorrect use of the function.
And why RefreshRates(); AFTER the order has been sent to the server? It's like to pay for something first and then ask "how much is it?
What kind of nonsense are you making here?
If the total number of orders and positions is 1 or more...
If an order is selected on an unknown ticket and it is not clear if it is closed or open...
...etc...
Do you think it helped?
... No orders means 0, and if there are orders, it's not just 1.
...This is where I will correct with permission so to speak.
In bool if there is 0 then it is false, everything else other than zero is true
OrderClose(OrderTicket(),0.01,Bid,2);
in "experts" it says "invalid ticket for OrderClose function".
Help? my goal is to close order on current chart.
To close a position with a ticket, you first need to know the exact ticket number of the position to be closed. Then you must select the order using the OrderSelect(ticket,SELECT_BY_TICKET) function, with verification of successful selection. Then we need to check the time of closing of the successfully selected order. Why? Because when we select by ticket, the pool parameter of the OrderSelect(..., ..., pool) function is ignored (it is used only when we select by index). And it means that even if we have successfully selected an order, we still need to know in which list we have chosen it - the list of closed or open positions. It is the check of close time that allows us to find out "if the order is still in the market". If the time of closing is equal to zero, the order is still in the market. If the time is different from zero, the order has already been closed earlier. And after all this procedure, we can send an order to close that order.
I have a chart in front of me. I see that an order is open on it. I decide to close it. that's it. nothing else is needed.
(I ask because. I can close with a "one-click trade" cross, but I'm very comfortable with the hotkeys)