Hi,
Im just getting to grips with MQ4 and have run into a problem when trying to use OrderModify. At this stage all I want to achieve is move my stop to B/E once 20 pips in profit.
Here's what I have so far (for long orders)...
This produces the following error:
OrderModify failed with error code: 1
According to the docs error 1 means ERR_NO_RESULT. I have a feeling the price parameter is wrong but since Im not modifying a pending order i dont know what to enter here. Also im unsure if the stop and TP params need to be multiplied by Point?
Can someone please point me in the right direction? Alternatively if someone has a much cleaner / better way of achieving this i'd be very grateful.
Many thanks!
Im just getting to grips with MQ4 and have run into a problem when trying to use OrderModify. At this stage all I want to achieve is move my stop to B/E once 20 pips in profit.
Here's what I have so far (for long orders)...
PHP Code
if (Ask == (higher+(20*Point))) {
if (OrderSelect(ticketBuy,SELECT_BY_TICKET)) {
if (OrderModify(OrderTicket(),Ask,OrderOpenPrice(),OrderTakeProfit(),0,Blue)) {
Print("Order ",OrderTicket()," moved to break even (",OrderOpenPrice(),")");
} else {
Print("OrderModify failed with error code: ",GetLastError());
}
} else {
Print("OrderSelect failed with error code: ",GetLastError());
}
}
OrderModify failed with error code: 1
According to the docs error 1 means ERR_NO_RESULT. I have a feeling the price parameter is wrong but since Im not modifying a pending order i dont know what to enter here. Also im unsure if the stop and TP params need to be multiplied by Point?
Can someone please point me in the right direction? Alternatively if someone has a much cleaner / better way of achieving this i'd be very grateful.
Many thanks!