OrderClose

 

Can any one explain?

the OrderSelect, OrderType and OrderClose functions am I using correctly ? 

I want to close a trade when the new high comes.

 if(OrdersTotal()>0

          && OrderSelect(ticketBuy,0,MODE_TRADES==true)

          && OrderType()==0)

       {

         //bool checkNewLow=getLow();

         if(Bid<lowofPinbar)

         {

            bool result= OrderClose(ticketBuy,lot,Bid,3,clrAqua);

            if(result==true)

               {

                  Alert("buy Order is closed succesfully.");

               }

            else 

            {

               Alert("buy Order close error.");

            }

          }  

        }
 
 && OrderSelect(ticketBuy,0,MODE_TRADES==true)

Where does the value for ticketBuy come from? In the above you are using it to locate a position in the trades list

bool result= OrderClose(ticketBuy,lot,Bid,3,clrAqua);

here you are using it as the actual Ticket#

It can't be both.

Don't use integers when you can use an enum, use SELECT_BY_POS or SELECT_BY_TICKET. 
 
Keith Watford:

Where does the value for ticketBuy come from? In the above you are using it to locate a position in the trades list

here you are using it as the actual Ticket#

It can't be both.

Don't use integers when you can use an enum, use SELECT_BY_POS or SELECT_BY_TICKET. I'am 

thank you for replying Keith.

I'm getting ticketbuy from the OrderSend function
you mean I should use ticketbuy either in OrderSelect or in OrderClose ?