Adding multiple Take Profits and Stops on one trade

To add comments, please log in or register
Thomas Stone
11
Thomas Stone  
I'm not a newbe on MT4 but I have a new requirement ot set up a list of Take Profits for partial close outs when you first trade. For example, buy 10 lots, TP 3 lost at +50, 3 lots at +100, and the final 4 at +200. I know I can do it manually but it was pointed out to me that it can be done automatically on other systems like GTS Pro. Is there any coding out there that will accomplish this?
Ray
2646
Ray  

you can use OrderSend() to close part of a position.

williams ojekunle
235
williams ojekunle  
phy:

you can use OrderSend() to close part of a position.


hi phy,

i know you are a great coder,but can you help me with an ea on parabolic sar? my e-mail is yemiojes@fastermail.com. Thanks.

gary
4
gary  
phy:

you can use OrderSend() to close part of a position.

Is there a script that is already written to take partial profit on orders that are active?

gary
4
gary  
TommyM:
I'm not a newbe on MT4 but I have a new requirement ot set up a list of Take Profits for partial close outs when you first trade. For example, buy 10 lots, TP 3 lost at +50, 3 lots at +100, and the final 4 at +200. I know I can do it manually but it was pointed out to me that it can be done automatically on other systems like GTS Pro. Is there any coding out there that will accomplish this?

TommyM

Did you ever get an answer to your question? I find it hard to believe that you just can't attach a sell order to modify your buy order by the number of lots...

rv
461
rv  
forexbomb wrote >>

TommyM

Did you ever get an answer to your question? I find it hard to believe that you just can't attach a sell order to modify your buy order by the number of lots...

extern double Lot=10;
extern int TP=200;
extern int TP1=50;
extern double Close1=3;
extern int SL1=10;

extern int TP2=100;
extern double Close2=3;
extern int SL2=50;

********************

double CP=0;

//here loop throw your open orders

//for buy orders:

CP=((Bid-OrderOpenPrice())/Point);

if (CP>TP1&&TP1>0)
{
if (OrderLots()==Lot)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+SL1*Point, OrderTakeProfit(), 0, Blue);
OrderClose(OrderTicket(),Close1,Bid,3,CLR_NONE);
}
}

if (CP>TP2&&TP2>0)
{
if (OrderLots()==Lot-Close1)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+SL2*Point, OrderTakeProfit(), 0, Blue);
OrderClose(OrderTicket(),Close2,Bid,3,CLR_NONE);
}
}

//sell orders

CP=((OrderOpenPrice()-Ask)/Point);

if (CP>TP1&&TP1>0)
{
if (OrderLots()==Lot)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()-SL1*Point, OrderTakeProfit(), 0, Blue);
OrderClose(OrderTicket(),Close1,Ask,3,CLR_NONE);
}
}

if (CP>TP2&&TP2>0)
{
if (OrderLots()==Lot-Close1)
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()-SL2*Point, OrderTakeProfit(), 0, Blue);
OrderClose(OrderTicket(),Close2,Ask,3,CLR_NONE);
}
}

more nice will be to include the "NormaliceDouble" also, i know :-)

To add comments, please log in or register