OrderModify function with price 0

 

Hi there,

I'm studying a mql4 code and I'm trying to understand that when modifying an open order it's ok to set for price parameter of OrderModify function the value zero.

I've seen a note here, that only for pending orders could be modified the price or expiration parameters, but what happen if price is set to 0 as I found in this code.

On another line of the same code, when the author it's using the OrderModify function again for an open order, for the price parameter, a variable "orderprice" it's used which takes the value of OrderOpenPrice().

Which way is ok or best practice to use the OrderModify function?

Thanks

Modification of Orders - Programming of Trade Operations - MQL4 Tutorial
Modification of Orders - Programming of Trade Operations - MQL4 Tutorial
  • book.mql4.com
MQL4 allows you to modify market and pending orders. Orders are modified according to the rules described in Order Characteristics and in Appendix 3. Function OrderModify() Trade requests for modifying of market and pending orders are formed using the function OrderModify(). The function modifies the parameters of market and pending orders. The...
 

Ordermodify has 3 price parameters.

It's a mystery to me which one you are referring to.

In the case of SL and TP then yes those can be zero but you might want to change either one of them or what is the purpose of the call.

In the case of OrderOpenPrice() of course this can not be zero, you did not open the order @ zero and it is a immutable value once the order is opened. 

 

The purpose of using OrderModify() function is to change SL and TP.

On some line the function looks like this:

OrderModify ( OrderTicket(), 0, neworderstoploss, newordertakeprofit, orderexpiretime, Lime )

and on another line like this:

orderprice = OrderOpenPrice(); // Get open price of the selected order
// Send a modify order for BUYSTOP order with new SL and TP
wasordermodified = OrderModify ( OrderTicket(), orderprice, neworderstoploss, newordertakeprofit, orderexpiretime, Lime );

I'd like to know if it's ok to use "0" for price parameter (not SL or TP) as it is used in the first case.

 

If its not ok it will throw a 130 invalid values error.

This also happens when you try to put TP and SL too close to the actual price.