Specifically, theAlert ("OrderTicket( )",OrderTicket( )) line; Which could mean that the last cycle is not completed!!!
Here's the log. Earlier, I often rewrote the code, I often encountered errors, I think4108 and 4050, now there is no error! Yeah, well, it's not working, anyway!
It's so right se... What did I messed up in the line?
Let's put it this way... So no one gets shot and you don't get ordered around... :))
Let's start in order. First, we'll find the last closed position and make sure it's closed at the take:
int j=-1;
datetime t;
// Поищем в цикле последнюю закрытую позицию, которая закрылась по TakeProfitfor (int i=0; i<OrdersHistoryTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()>1) continue;
if (OrderMagicNumber()==1000 || OrderMagicNumber()==2000) {
if (t<OrderCloseTime()) {
t=OrderCloseTime();
j=i;
}
}
}
}
if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
if (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)<0.5*Point) {
Alert("Позиция с тикетом #",OrderTicket()," закрыта по TakeProfit, закрываем остальные прозиции и удаляем отложенные ордера");
// Здесь код для закрытия всех открытых позиций (тоже в цикле)// Здесь код для удаления всех отложенных ордеров (также в цикле)
}
}
This:
// Здесь код для закрытия всех открытых позиций (тоже в цикле)// Здесь код для удаления всех отложенных ордеров (также в цикле)
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.
Specifically, theAlert ("OrderTicket( )",OrderTicket( )) line; Which could mean that the last cycle is not completed!!!
Here's the log.
Earlier, I often rewrote the code, I often encountered errors, I think4108 and 4050, now there is no error! Yeah, well, it's not working, anyway!
Yeah, well, I guess that's where it gets tricky.
if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()
|| OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()) {
That's right, s... What did I do wrong in the line?
Yeah, well, I guess that's where it gets tricky.
if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()
|| OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()) {
That's right, s... What did I do wrong in the line?
only by this point it could be a remote pending order and the result would be unusual ;)
I don't understand, it's not deleted I'm selecting here, not fashion histories. OK, no need, that's later.
-AAH!!! So I'll bracket both sides!!! THANK YOU!!!!!
Whew!!!
Okay, I'm gonna go take a shower. It's hot.
I don't get it, I'm not culling the deleted ones, not the fashion histories. Ok, no need, that's later.
Let's assume we have 1 pending order to delete and we have reached the line (for ease of reading, I broke it down by operator)
So, we have this order:
1) we delete it, and in doing so:
a) we are lucky and it is deleted
b) it may not be deleted because the price is too close/the server is overloaded/the Internet is down/etc. But we go ahead anyway.
2) if something goes wrong, we write it down
3) close the order (pending!!! which we deleted in the first point!!!)
result... I can't predict 100%, but it looks like another error
4) display a message about it
Yeah, well, there's the problem.
if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()
|| OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()) {
It's so right se... What did I messed up in the line?
Let's put it this way... So no one gets shot and you don't get ordered around... :))
Let's start in order. First, we'll find the last closed position and make sure it's closed at the take:
This:
This will be your homework... :)