[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 284

 

Buy should close on Bid.
Sat on Asc.

 
sergeev:


Buy should close on Bid.
Sat on Asc.


OK, corrected.

Is there anything else that catches your eye?

 
BBSL:


OK, corrected.

Is there anything else that catches your eye?

Damn... :)))))))))))))))))
 
artmedia70:
The devils... :)))))))))))))))))

With scythes?))
 
sergeev:


Buy should close on Bid.
Sat on Asc.


Still doesn't close...

Although the signal (writing down all the file) to close...

 
BBSL:


Still won't close...

Although the signal (writing all the file) to close...

error
OrderSelect(order_id, SELECT_BY_POS)==true

or order_id with SELECT_BY_TICKET

or 0 with SELECT_BY_POS

In general, explain - why do you make two consecutive OrderSelect?

 
sergeev:
error

or order_id with SELECT_BY_TICKET

or 0 with SELECT_BY_POS

And in general, explain - why do you do two consecutive OrderSelect ?


Thank you, sergeev!

Second check))

Inexperience, I should probably remove it...

 
BBSL:


Thank you, sergeev!

Second check))

Inexperienced, need to remove, I guess...


Shit, I'm sorry, but it's not closing again...

please assist

 
show
 
sergeev:
show
int send_orders(bool signal, int position_limit, string file_name){

int ticket_count = OrdersTotal();


if (ticket_count < position_limit){

Print("send_orders ticket_count = ", ticket_count);

if (signal == true){

Print("send_orders, signal BUY");

   order_id = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,Green);
   if(order_id < 0)
     {
      error=GetLastError();
      Print("send_orders, error = ",ErrorDescription(error));
      return;
     }
}if (signal == false){

Print("send_orders, signal SELL");

   order_id = OrderSend(Symbol(),OP_SELL,1.0,Bid,3,0,0,"expert comment",255,0,Red);
   if(order_id < 0)
     {
      error=GetLastError();
      Print("send_orders, error = ",ErrorDescription(error));
      return;
     }
     }

}if (ticket_count == position_limit){

OrderSelect(0,SELECT_BY_TICKET);

order_type = OrderType();

order_id = OrderTicket();

//----

Print("send_orders,  order already open");

if ((signal == false) && order_type == OP_BUY){

Print("send_orders,  is closing position");

if(OrderSelect(0, SELECT_BY_TICKET)==true){

OrderClose(OrderTicket(),1,Bid,3,Red);

}

}if ((signal == true ) && order_type == OP_SELL){

Print("send_orders,  is closing position");

if(OrderSelect(order_id, SELECT_BY_TICKET)==true){

OrderClose(OrderTicket(),1,Ask,3,Red);

}
}
}
}

The first is OrderSelect(0,SELECT_BY_TICKET); it needs order_type == OP_BUY to work, but in this case it does not work.

Thank you for your help.