OP_SELLSTOP SL and TP being modified by MT4 when target price is reached?

 

Testing an EA in Strategy Tester. I am setting up pending BUYSTOP or SELLSTOP orders. When the order price for the BUYSTOP is reached the order is executed as expected (see code snippet)

         price=(H+(1*EApips));

         lotsize=0.1;

         Initbsl=(price-(InitSL*EApips));

         btp=(price+(InitTP*EApips));

         expiry=TimeCurrent()+(OrderExpireTime*3600);

         //

         //Enter Initial Trade

         InitTicket=OrderSend(Symbol(),OP_BUYSTOP,lotsize,price,3,Initbsl,btp,NULL,MagicNumber,expiry,clrGreen);


Teh code below is almost identical to the BUYSTOP code... When the order price for a SELLSTOP order is reached the order is executed BUT it is also being immediately modified to remove the SL and TP levels specified when the pending order was placed.

         price=(L-(1*EApips));

         lotsize=0.1;

         Initssl=(price+(InitSL*EApips));

         stp=(price-(InitTP*EApips));

         expiry=TimeCurrent()+(OrderExpireTime*3600);

         //

         //Enter Initial Trade

         InitTicket=OrderSend(Symbol(),OP_SELLSTOP,lotsize,price,3,Initssl,stp,NULL,MagicNumber,expiry,clrRed);

I do not have any OrderModify() in my code... Here are the results...

Results...

Any ideas on what is going on here?

 
  1. You buy at the Ask and sell at the Bid.
    • Your buy order's TP/SL are triggered when the Bid reaches it. Not the Ask.
    • Your sell order's TP/SL will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 3
    • The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools -> Options {control-O} -> charts -> Show ask line.)

  2. see also
              Chart Price Max/Min - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. It doesn't modify itself, you have (broken) code running on some chart.
  4. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
Reason: