How to check if an order has been closed for stop loss - page 3

 
honest_knave:
What about slippage?
<= for Buys and >= for Sells.
 
Jose Francisco Casado Fernandez:
Yes, it's what I was saying. I did it so, and it worked, but if you modify the initial Stop Loss, it generates a new order WITHOUT the same POSITION_ID. I don't know why. I think, it is a bug. Regards,.
I will check on this issue, Thank you and regards.
 
Roberto Jacobs:

No need to look slippage, because the order has been close, and close price is on HystoryDealGetDouble(ticket, DEAL_PRICE).
If the order has not been in close, and you make an order to close, then you should consider how much slip, so that no error requotes.

If I understand you correctly, that's not exact. On a real market, an order can be closed by SL (or TP) at a different price that the position SL (or TP).
 
Roberto Jacobs:

No need to look slippage, because the order has been close, and close price is on HystoryDealGetDouble(ticket, DEAL_PRICE).
If the order has not been in close, and you make an order to close, then you should consider how much slip, so that no error requotes.

I'm not sure I follow.

HistoryOrderGetDouble(ticket,ORDER_SL) is the stop loss

When the SL is triggered, you can get slippage.

HistoryDealGetDouble(ticket, DEAL_PRICE) will show the actual price, which may or may not have encountered slippage.

If there was slippage, a simple comparison of ORDER_SL == DEAL_PRICE will fail, no? 

 
Jose Francisco Casado Fernandez:
Yes, it's what I was saying. I did it so, and it worked, but if you modify the initial Stop Loss, it generates a new order WITHOUT the same POSITION_ID. I don't know why. I think, it is a bug. Regards,.

An order to modify SL/TP is not saved in the history at all. So not sure what you mean here ?

And the order which actually results from the SL/TP triggered doesn't contain the SL/TP.

 
Jose Francisco Casado Fernandez:
<= for Buys and >= for Sells.
What about positive slippage?
 
honest_knave:

I'm not sure I follow.

HistoryOrderGetDouble(ticket,ORDER_SL) is the stop loss

When the SL is triggered, you can get slippage.

HistoryDealGetDouble(ticket, DEAL_PRICE) will show the actual price, which may or may not have encountered slippage.

If there was slippage, a simple comparison of ORDER_SL == DEAL_PRICE will fail, no? 

Of course.
 
Alain Verleyen:
If I understand you correctly, that's not exact. On a real market, an order can be closed by SL (or TP) at a different price that the position SL (or TP).
Yes Alain, what if  Bid > close_price+spread    or   Ask < close_price-spread
 
Roberto Jacobs:
Yes Alain, what if  Bid > close_price+spread    or   Ask < close_price-spread

spread != deviation (slippage)

It is a shame it is not possible to retrieve the deviation parameter.

Probably a reasonable compromise is (presuming the EA placed the order) to check whether DEAL_PRICE was within a window of ORDER_SL ± deviation

 
Roberto Jacobs:
Yes Alain, what if  Bid > close_price+spread    or   Ask < close_price-spread
Sorry but I don't understand what you mean ?
Reason: