Problem in Trailing Stop

 

Hello!

I have a strange problem with Trailing stop. I did my own but I always get 130 error. I saw the page: https://book.mql4.com/appendix/limits and after that, I can't understand the error...

 The code is:

extern int DistanceTS = 20;

...

if (OrderType() == OP_SELL) {
        double stopLoss = NormalizeDouble(Ask + DistanceTS * Point, 4);
        if (stopLoss < OrderOpenPrice()) {
                if (stopLoss < OrderStopLoss()) {
                        int resultModifySell = OrderModify(OrderTicket(), OrderOpenPrice(), stopLoss, 0, 0, Blue);
                        showList(stopLoss + " Modify: " + resultModifySell + " (" + GetLastError() + ")");
                }
        }
}

 

Could ou help me? 

 

Thank you in advance! 

 

https://docs.mql4.com/trading/errors

ERR_INVALID_STOPS    130    Stops are too close, or prices are ill-calculated...

Are you making sure stops are not too close to current bid/ask?

Are you adjusting for 4/5 digit brokers?

Tips: For current price try using OrderClosePrice().

Tips: Distance must be greater than MarketInfo ... StopLevel.

 
        double stopLoss = NormalizeDouble(Ask + DistanceTS * Point, 4);
  1. Moving SL 2 pips above market (5 digit broker)
  2. StopLevel
  3. Did you OrderSelect first
  4. It is never necessary to normalizeDouble, ever. It's a cludge, don't use it. https://www.mql5.com/en/forum/137301
 

Wow!

Thank you a lot! The problem was that the minimum (SL) was bigger that I had imagined!

 

I solve the problem. Thank you!! :) 

Reason: