Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1110
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
Returns error 4108 sometimes - wrong ticket for OrderClose. Is it possible that OrderTicket() does not match the ticket in OrderSelect? The ticket variable can be equal to zero.
It takes me a long time to reproduce the error, it's easier to ask.Returns error 4108 sometimes - wrong ticket for OrderClose. Is it possible that OrderTicket() does not match the ticket in OrderSelect ? The ticket variable can be equal to zero.
It takes me a long time to reproduce the error, it's easier to ask.You select an order by ticket. Are you sure that the selected order is not already closed? But you try to close it again ... Check the closing time after successfully selecting the ticket.
You are selecting the order on the ticket. And you are sure that the selected order is not already closed? But you are trying to close it again. Check the closing time after a successful selection on the ticket.
I'll check when I reproduce the error. I have all tickets stored in global variables. When the order is closed, they are deleted. Before OrderSelect() ticket is taken from global variables. If the ticket is not in variables - this variable will be 0, and thus the order should not be selected and OrderSelect() will return false. But in general, yes, it's worth checking. Thank you.
I'll check when I reproduce the error. I have all tickets stored in global variables. When the order is closed, they are deleted. Before OrderSelect() ticket is taken from global variables. If the ticket is not in variables - this variable will be 0, and thus the order should not be selected and OrderSelect() will return false. But in general, yes, it's worth checking. Thank you.
It is standard to check the closing price when an order is selected by ticket. You wouldn't know in any other way if the order is closed and selected from the list of closed orders, or if it is still open and selected from the list of market orders.
The most shortsighted way is to store tickets in global variables. They should be taken from the trading environment - the current information is there.
It is standard to check the closing price when an order is selected by ticket. You will not know in any other way if the order is closed and selected from the list of closed, or if it is still open and selected from the list of market ones.
It is the most short-sighted to store tickets in global variables. They should be taken from the trading environment - the current information is there.
If I select like this: OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES), is it supposed to partially solve the problem? I store tickets in global variables for other reasons, well, I used it in this case too.
If I select like this: OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES), is it supposed to partially solve the problem? I store tickets in global variables for other reasons, and I used them in this case as well.
No, it won't - pool (MODE_TRADES) is ignored during selection by ticket.
Returns error 4108 sometimes - wrong ticket for OrderClose. Is it possible that OrderTicket() does not match the ticket in OrderSelect ? The ticket variable might be equal to zero.
It takes me a long time to reproduce the error, it's much easier to ask.It is usually sufficient to check for market orders:
OrderCloseTime() == 0 //order is open
OrderCloseTime() > 0 //the order is closed
for limit orders, you should also check the close price; if it is equal to 0, the limit order has been cancelled
Hello!
Share the code using the PositionClosePartial method, if you can.
Theoretically I understand how it works, but I'd like to see some working code.
Or advise me where to look.
Thank you in advance.
Hello!
Share the code using the PositionClosePartial method, if you can.
Theoretically I understand how it works, but I'd like to see some working code.
Or advise me where to look.
I am grateful in advance.
Actually it is just one line of code. But you have to get the position ticket for it. Here is the Expert Advisor from OnInit that opens position with 0.2 lot and closes half of position in OnTick.
Or here is the full code from the CTrade class