ordermodify() error 1 on pending order price change AND Stoploss change

 

Getting around to doing cleanup on EA's YEA! and have a persistent error 1 problem when changing the price of a pending order. This situation has risen thanks to the D... A.. I..... at the CFTC and NFA for compromising our 1st Amendment rights in the US to trade as we see fit. It is one thing for government to protect against shifty brokerages, it is quite another to dictate how one can strategize their trading. OK enough politics,

Because of the hedge rule, when implementing a price straddle strategy

Entry prices straddle current price waiting for a Bid or Ask breakout.

When one of the pending stop orders is triggered, the other stop order must be modified so that in the case of a catastrophic stop loss, the other pending order may execute without causing issues to the currently open order. In this strategy the other pending order price in changed to be one greater or lessor than the stoploss of the current open order.

In this example the OP_BUYSTOP is triggered and the order moves to OP_BUY. The OP_SELLSTOP order is modified for the new entry price of 1 PIP less than the OP_BUY stoploss.

OrderModify() OP_SELLSTOP price 1 PIP less than OP_BUY Stoploss

The EA executes the requirement except that an ERROR 1 is generated. As many have stated, cruising the documentation this error when none of the modify parameters from the open order to the modified order is changed.

for the case of pending orders, I am believe that the MQL4 code base is not robust enough to determine that the price was changed, only checking for a change in limit or stoploss price. Thus the ERROR 1 is falsely generated for a successful order.


08:35:10 2011.01.24 02:52 USDCHF,H1: open #2 sell stop 0.07 USDCHF at 0.9542 sl: 0.9629 tp: 0.9455 ok


08:35:22 2011.01.24 03:27 USDCHF,H1: modify #2 sell stop 0.07 USDCHF at 0.9536 sl: 0.9629 tp: 0.9455 ok
08:35:22 2011.01.24 03:27 USDCHF,H1: OrderModify error 1

Can a moderator confirm that when changing the price without changing the SL or TP an ERROR 1 should not be generated and thus can be ignored?

ADDENDUM:

Digging a little more into my log files I see that on changing the Stoploss to protect profits, I again get an ERROR 1. It is seeming to me, that the MQL4 base code expects all three parameters of a OrderModify() to change, or, one always gets an Error 1 on use of OrderModify(). Fortunately, this does not affect the operation of my EA, BUT I like to understand why errors are or aren't being generated, as a retired test engineer, I don't like messy code.

As the trade progresses, A target point is hit and the Stoploss is moved to Break Even Entry point to protect profits and eliminate losses. Unfortunately this again generate an ERROR 1 where only the stoploss has changed and not the limit.


09:33:45 2011.01.24 00:00 USDCHF,H1: open #2 sell stop 0.07 USDCHF at 0.9542 sl: 0.9629 tp: 0.9455 ok


09:34:35 2011.01.24 10:33 USDCHF,H1: close #2 sell 0.04 USDCHF at 0.9542 sl: 0.9629 tp: 0.9455 at price 0.9504


09:34:35 2011.01.24 10:33 USDCHF,H1: modify #3 sell 0.03 USDCHF at 0.9542 sl: 0.9542 tp: 0.9455 ok
09:34:35 2011.01.24 10:33 USDCHF,H1: OrderModify error 1

 

Can a moderator or MetaQuotes Engineer comment on Error 1?

Even to say that this is a corner case attribute of MT4 and is not worth the effort to fix.

 
08:35:10 2011.01.24 02:52 USDCHF,H1: open #2 sell stop 0.07 USDCHF at 0.9542 sl: 0.9629 tp: 0.9455 ok
08:35:22 2011.01.24 03:27 USDCHF,H1: modify #2 sell stop 0.07 USDCHF at 0.9536 sl: 0.9629 tp: 0.9455 ok
08:35:22 2011.01.24 03:27 USDCHF,H1: OrderModify error 1

The TP/SL values in the modify exactly match the open, so error 1 is correct.

Your long winded post states you want to modify the OTHER, PENDING, order. You're not.

 

The post is long winded to give ALL data.

Indeed the SL and TP prices are the same for the modified order; HOWEVER, the entry price has changed. The OTHER, PENDING, order IS being modified for the entry price and not the Stop or Target prices which remain valid in the event of a head fake/whipsaw.

BY WHRoeder explanation;

This is MUST BE considered a bug (oversight) in the ERROR 1 code in that an error should not be triggered when an order IS successfully modified,

ERROR 1 should only be triggered when EP, SP and TP are all the same value as OrderOpenPrice(), OrderStopLoss() and OrderTakeProfit().

pseudo-code:

if (EP == OrderOpenPrice() &&

SP == OrderStopLoss() &&

TP == OrderTakeProfit())

{

ERROR1()

}


An ERROR1 should be the XOR of EP TP and SP not just the XOR of TP and SP.