looking for a way to close my open order by a certain amount of profit is it possible??

Back to topics list To post a new topic, please log in or register
avatar
14
mrgoodprice144 2016.04.07 17:27
 

I 'm looking a way to close my open order by a certain amount of profit is it possible ?? or do i have to close my open order only when the price is above the orderPrice ?? here is my code that close an open order:

 for(PositionIndex=TotalNumberOfOrders-1; PositionIndex>=0; PositionIndex --)
     {

                                      if(!OrderSelect(PositionIndex,SELECT_BY_POS,MODE_TRADES))

         if((OrderMagicNumber()==ticket1 || OrderMagicNumber()==ticket2) && OrderSymbol()=="EURUSD" && (ticket1==OP_BUY || ticket2==OP_SELL))//
              
               
                                      if(OrderType()==OP_SELL   )//SELL ORDER On Positif TRADE

                                      if(!OrderClose(ticket2,0.01,Bid-Price*Point ,clrNONE))


                 Print("Order Close failed, order number: ",ticket2," Error: ",GetLastError());
         
                                      if(OrderType()==OP_BUY   )//BUY ORDER On Positif TRADE

                                      if(!OrderClose(ticket1,0.01,Ask+Price*Point,5,clrNONE))
            
          
                 Print("Order Close failed, order number: ",ticket1," Error: ",GetLastError());
            
 
            
     }
avatar
35
sokramm 2016.04.08 18:44 #
 
Are you asking about a Take Profit order? If you isse an OrderClose request, you have to use current market value. Something different is a Limit order. Not sure what you are asking about...
avatar
14
mrgoodprice144 2016.04.08 20:14 #
 
Well let say when my BUY pending order is hit at 1.1373 EURUSD  and i want my EA to close that order at 1.1378 that is what i'm talking about.
avatar
13009
WHRoeder 2016.04.08 21:11 #
 
These will not work. You can only close an order at current market price.
if(!OrderClose(ticket2,0.01,Bid-Price*Point ,clrNONE))
if(!OrderClose(ticket1,0.01,Ask+Price*Point,5,clrNONE))
i want my EA to close that order at 1.1378
When you open the order, set the TP at that price and it will close itself.

Back to topics list  

To add comments, please log in or register