Modifying orders Question

 

Hi,


Im working on an EA (really just leaning how to program in MT4 ) And I had an idea and I want to know if its possible.


First let there be a condition and the EA opens an order With no SL or TP (I know this is not practical, but bare with me)


OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"Well Placed Order",magic,12345,Green);


Now that I have placed the order, Is there a way to modify it later to buy more lots at a different ask price but add them to the same order? So that one order would have 1 lot at 1.40000 and 1 lot at 1.41000 but have them be part of the same order?


Also, Is there a way that I could sell only part of my 1 lot in the order and keep the rest of the lots in the order so the order isn't closed? for example, say I wanted to sell 0.5 lots at 1.41000 but I wanted to keep the other 0.5 lots still open?


Anyone know how to do that?

 
Bondy3:

Hi,


Im working on an EA (really just leaning how to program in MT4 ) And I had an idea and I want to know if its possible.


First let there be a condition and the EA opens an order With no SL or TP (I know this is not practical, but bare with me)



Now that I have placed the order, Is there a way to modify it later to buy more lots at a different ask price but add them to the same order? So that one order would have 1 lot at 1.40000 and 1 lot at 1.41000 but have them be part of the same order?


Also, Is there a way that I could sell only part of my 1 lot in the order and keep the rest of the lots in the order so the order isn't closed? for example, say I wanted to sell 0.5 lots at 1.41000 but I wanted to keep the other 0.5 lots still open?


Anyone know how to do that?

Check the documentation for OrderModify().

Check OrderLots() and NormalizeDouble() also.

To close part of the lots opened you have to use OrderClose() function and pass to it as a parameter the number of lots you want to clse, for example NormalizeDouble(OrderLots()/2,1).

Reason: