Please help me solve a problem I've been struggling with for a month.
My TS sometimes doesn't close orders for some reason.
It looks like this:
The first three orders - 44329646, 44330563 and 44337351 open and close fine.
And on the fourth order, the tragedy happens:
and so on to infinity...
That is, an Expert Advisor opens order 44339156 and tries to close order 44337351 that it itself (!!!!) successfully closed several hours earlier.
You have to close it manually; if you fail to do that, you will sometimes suffer from the deepest drawdown. What a disaster!
How is it possible?
The code of the Expert Advisor is as simple as can be:
How can one and the same program work "time after time"? I do not understand...
Read the Help for OrderSelect(). In particular, read the reference on selection by ticket. Even a closed order is selected by ticket. It is already closed, and you are trying to close it again.
If 0, it means that it is still in the market, close it, if > 0, it means that it is already closed and there is no need to kick it again, it will not come to life and will not close.
Read the help for OrderSelect(). Particularly about selection by ticket. Even a closed order is selected by the ticket. It is already closed, and you are trying to close it again.
If it is selected, check the closing time - if 0, it means it is still in the market - close it, if > 0, it means it has already been closed and you do not have to kick it again - it will not come to life and will not close.
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.
YES. This is exactly what Sergei Kovalev's textbook is all about. It is the one that is missing a lot at the moment.
There is no textbook on mql5 as such on this site, I don't know about others. But there are a lot of articles, read them, you may succeed.
Gentlemen programmers!
Please help me solve a problem I've been struggling with for a month.
My TS sometimes doesn't close orders for some reason.
It looks like this:
The first three orders - 44329646, 44330563 and 44337351 open and close perfectly.
And on the fourth order, the tragedy happens:
and so on to infinity...
That is, an Expert Advisor opens order 44339156 and tries to close order 44337351 that it itself (!!!!) successfully closed several hours earlier.
You have to close it manually; if you fail to do that, you will sometimes suffer from the deepest drawdown. What a disaster!
How is it possible?
The code of the Expert Advisor is as simple as can be:
здесь - условие открытия сделки { RefreshRates(); total_orders_NZDUSD=TotalOrders("NZDUSD.I"); if(total_orders_NZDUSD==0) { Balance=AccountBalance(); Lots=NormalizeDouble((Balance/(Ask*10.0))*0.01,2); double AskNorm=NormalizeDouble(Ask,Digits); ticket_buy_NZDUSD=OrderSend("NZDUSD.I",OP_BUY,0.01,AskNorm,0,0,0); } } здесь - условие закрытия сделки { RefreshRates(); if(OrderSelect(ticket_buy_NZDUSD, SELECT_BY_TICKET)==true) { total_orders_NZDUSD=TotalOrders("NZDUSD.I"); ctm_ticket_buy_NZDUSD=OrderCloseTime(); order_type_NZDUSD=OrderType(); if(total_orders_NZDUSD>0) { if(ctm_ticket_buy_NZDUSD==0) { if(order_type_NZDUSD==OP_BUY) { double BidNorm=NormalizeDouble(Bid,Digits); OrderClose(ticket_buy_NZDUSD,0.01,BidNorm,0); } } } }How can one and the same program work "time after time"? I don't understand...
Gentlemen programmers!
Please help me solve a problem I've been struggling with for a month.
My TS sometimes doesn't close orders for some reason.
It looks like this:
The first three orders - 44329646, 44330563 and 44337351 open and close fine.
And on the fourth order, the tragedy happens:
and so on to infinity...
That is, an Expert Advisor opens order 44339156 and tries to close order 44337351 that it itself (!!!!) successfully closed several hours earlier.
You have to close it manually; if you fail to do that, you will sometimes suffer from the deepest drawdown. What a disaster!
How is it possible?
The code of the Expert Advisor is as simple as can be:
How can one and the same program work "time after time"? I do not understand...
Read the Help for OrderSelect(). In particular, read the reference on selection by ticket. Even a closed order is selected by ticket. It is already closed, and you are trying to close it again.
If 0, it means that it is still in the market, close it, if > 0, it means that it is already closed and there is no need to kick it again, it will not come to life and will not close.
Read the help for OrderSelect(). Particularly about selection by ticket. Even a closed order is selected by the ticket. It is already closed, and you are trying to close it again.
If it is selected, check the closing time - if 0, it means it is still in the market - close it, if > 0, it means it has already been closed and you do not have to kick it again - it will not come to life and will not close.
Thank you very much - I will try.
Thank you very much - I will give it a try.
You're welcome. You don't have to try it, you have to do it...
Please. You don't have to try it, you have to do it...
Artem, I have read the help - everything seems to be correct.
I am checking the closing time.
I have read it in MQL4 Reference:
It is recommended to call the OrderSelect() function immediately before calling for the latest order data.
This is also true.
Then what is wrong?
Artem, I have read the help - everything seems to be correct.
I am checking the closing time.
I have read it in MQL4 Reference:
It is recommended to call the OrderSelect() function immediately before calling for the latest order data.
This is also true.
Then what's wrong?
What kind of function is this?
total_orders_NZDUSD=TotalOrders("NZDUSD.I");And after it has been worked, which order is allocated?Gentlemen programmers!
Please help me solve a problem I've been struggling with for a month.
My TS sometimes doesn't close orders for some reason.
It looks like this:
The first three orders - 44329646, 44330563 and 44337351 open and close fine.
And on the fourth order, the tragedy happens:
and so on to infinity...
That is, an Expert Advisor opens order 44339156 and tries to close order 44337351 that it itself (!!!!) successfully closed several hours earlier.
You have to close it manually; if you fail to do that, you will sometimes suffer from the deepest drawdown. What a disaster!
How is it possible?
The code of the Expert Advisor is as simple as can be:
How can one and the same program work "time after time"? I don't understand...
what direction are you looking at the order array ?
If there are possible closures/deletions during "revision", it's better to look in the opposite direction. From OrdersTotal()-1 to 0 inclusive.
Otherwise, you may step on it :-)
What is this feature?
This function was kindly given to me by Goldtrader, for which I am sincerely grateful.
It allows you to open orders simultaneously for different currency pairs.
:))) In my opinion, it is what started it all, because I enabled it about a month ago... Without it I cannot see the Grail.
Something wrong with it?
There's something really wrong, though...
I mean, I doOrderSelect once and then again from the function... It doesn't make sense...