Modify orders and close pending orders

To add comments, please log in or register
bkgridley
20
bkgridley  

I'm trying to create an EA that does three things:

1. modifies my existing (manual) orders SL when I am at a certain profit level.

2. Close all other pending orders when I have made this modification.

3. I also want to continue modifying my orders (basically a 40 point TS) when the price moves in my favor.

If any one can help it would be appreciated.

bkgridley
20
bkgridley  

clarification

When one of my orders hits a certain profit level, I want to modify SL on all orders.

pusher
5
pusher  

I'm trying to do pretty much the same thing, but mines not working.

int start()

{

//----

if(OrdersTotal()<1)

{

OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+10*Point,"1st Contract",0001,0,Green);

OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+25*Point,"2nd Contract",0002,0,Yellow);

OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+50*Point,"3rd Contract",0003,0,Red);

OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+100*Point,"4th Contract",0004,0,Blue);

}

OrderSelect(0004, SELECT_BY_TICKET);

double Price=OrderOpenPrice();

if(Ask==Price+10)

{

OrderModify(0002,OrderOpenPrice(),Price*Point,OrderTakeProfit(),0,Yellow);

OrderModify(0003,OrderOpenPrice(),Price*Point,OrderTakeProfit(),0,Red);

OrderModify(0004,OrderOpenPrice(),Price*Point,OrderTakeProfit(),0,Blue);

}

if(Ask==Price+25)

{

OrderModify(0003,OrderOpenPrice(),Price+10*Point,OrderTakeProfit(),0,Red);

OrderModify(0004,OrderOpenPrice(),Price+10*Point,OrderTakeProfit(),0,Blue);

}

if(Ask==Price+50)

OrderModify(0004,OrderOpenPrice(),Price+25*Point,OrderTakeProfit(),0,Blue);

if(Ask==Price+75)

OrderModify(0004,OrderOpenPrice(),Price+50*Point,OrderTakeProfit(),0,Blue);

//----

return(0);

Not sure why, but it didn't adjust stop loss levels.

bkgridley
20
bkgridley  

my code is similar and doesn't work either

pusher
5
pusher  

Found one potential problem, I think I needed to change the values in my if statements with the Point constant.

EX:

if(Ask==Price+10*Point)
Achilles
4
Achilles  

....

OrderSelect(0004, SELECT_BY_TICKET);

....

I think you start your search with that line. In that line you are only selecting the trade belonging to that spesific ticket (0004), and any modifications you order later on in the code, will only affect that particular order...

Solution, you need to loop through each pending order and select them each, do the modification and then move on to the next one...

Take care,

pusher
5
pusher  

Could be true, but I just figured Ordermodify had Orderselect built in since I'm having to already call the ticket number in Ordermodify. Can you confirm thats how the magic number works in Ordersend? I give it the number 0004 so when I want to call it with Ordermodify I just use the ticket number 0004?

ashnou
4
ashnou  

i don't know much about mql4 programming

i only did vb6

my idea is why dont u make an ea to open or to put order manualy . then it will be easyer for the ea to handle (take control )these already opened order by it

sorry if it is bad idea and for my bad english

martingalaj
20
martingalaj  

idea

somebody can do that?

Add at one EA (i have one winning ) that function:

Close orders if win 5% on balance account.

thanks

To add comments, please log in or register