Martingale with step - page 2

 

I am asking are there any more ideas for a reliable check for closing on SL/TP on MT4?

MT5 has the ORDER_CLOSE_REASON field. MT4 does not have it.

 
Alain Verleyen #:

At least William version would deal with such slippage, most of the time.

It's not an easy issue to solve in a general way.

isTP = |OCP-OTP| < |OCP-OSL| is also not precise! The latter condition might also be fulfilled for any manually-closed order (i.e. a non-specific test).

Better is a combined approach:

         else if ((OrderType() == OP_BUY && GTE(OrderClosePrice(), OrderTakeProfit()))
               || (OrderType() == OP_SELL && LTE(OrderClosePrice(), OrderTakeProfit()))
               || (StringFind(OrderComment(), "TP") > 0)
               || (fabs(OrderClosePrice()-OrderTakeProfit()) < fabs(OrderClosePrice()-OrderStopLoss())))
         {
            lossCount = 0;
         }
I am not sure 100%