Newbie questions - Why do my Sell Stop orders keep getting deleted?

 

Hi,

I'm new to MQL4 and am currently trying to write a hedging EA. The logic appears OK but when I back test the EA in MT4 on my test broker account I notice that some of my Sell Stop orders are mysteriously deleted in the trade results window. My EA code certainly isn't deleting the Sell Stops. What could the reasons for this be? Any help would be most appreciated.

Thanks

Mjj

 
Does it have any Expiration Time when being sent? Is there an OrderDelete() command anywhere in your codes? Was the Pending Order Ever created there to begin with? Is the broker a Non-Hedge Broker? Is there any OrderCancelOrder logics? Are you testing this Live or within Strategy Tester? Did you check the Logs and Last Errors?
 

Hi,

I am testing the EA with Strategy Tester. I am placing the pending orders as follows:

ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,firstBuyPrice,3,firstBuyStop,firstBuyTakeProfit,"",MAGICMA,0,Orange);

You can see that no expiry is set.

I think the pending order is deleted when it becomes active possibly due to margin and the size of the lots I am using. The pending orders increase in size until a target progit is reached.

The pending orders don't appear to be deleted with smaller lot sizes. There are no clues in the error logs.

 
The history tab should have the clues that shows a deleted pending order or a closed market order.
 
ubzen:
The history tab should have the clues that shows a deleted pending order or a closed market order.

Yep the history tab shows a deleted pending order. The question is why was it deleted? My EA code didn't delete it. The only thing that I can think of is that the buy price for the pending order was met but it couldn't be opened due to the lot size and therefore it is deleted automatically?
 
Try printing the GetLastError when the OrdersTotal() change. Example if ( OrdersTotal() != Last_Time_I_Counted ){ Last_Time_I_Counted= OrdersTotal(); Print(GetLastError); }
Reason: