Download MetaTrader 5
To add comments, please log in or register
Hundreds of articles will help you to create a trading robot. Come and read them!
MisterDog
380
MisterDog 2014.03.18 06:03 

I'm not sure how to take part of my profits at a price before Take Profit line of an order. I place an order with code that looks something like this...

         OrderSend(Symbol(),OP_BUY,0.10,Ask,3,stopLoss,takeProfit,"",Magic,0,clrGreen);

And then when the price reaches 10 pips I would like to take partial profits. Do I create a new limit order? Do I use the OrderSend with the OP_SELLLIMIT? Something like this...

  OrderSend(Symbol(),OP_SELLLIMIT,0.05,Ask+0.0010,3,0,0,"",Magic,clrGreen);

 

Thanks,

Keith Watford
Moderator
7984
Keith Watford 2014.03.18 07:32  

No

First you have to select the order, then check that Bid is at the price to take partial profit

OrderClose(OrderTicket(),0.05,Bid,30,clrGreen)

That would close 0.05 lots and the broker will open a new ticket with the remaining lots

That is, of course assuming that the minimum lot size is not 0.10

/
To add comments, please log in or register