If your stop distance is too low, increase it. The API can not fix it since the fill price of a trade is unknown beforehand. Quote differences of 3 pips or more are not uncommon.

Many brokers do not accept stop loss orders at a distance less than 10 pips anyway.