What will happen if I send a five digit price to a four digit broker?

 

Just that question.  Am adding 4/5 digit broker detection to an ea I wrote on a 5 digit broker.  On the 5 digit broker I might send an order with a take profit or a stop loss of say 125 points which would be translated to 12.5 points for the 4 digit broker.  So adding that to the four digit price would give five digits and might cause an error.   Is it typical to just limit the tp or sl on a five digit broker to a multiple of 10 and truncate or round that extra digit off?

Thanks,

 

You have to normalize your price. See documentation of OrderSend.

Calculated or unnormalized price cannot be applied. If there has not been the requested open price in the price thread or it has not been normalized according to the amount of digits after decimal point, the error 129 (ERR_INVALID_PRICE) will be generated.

 
niqmadu: I might send an order with a take profit or a stop loss of say 125 points which would be translated to 12.5 points for the 4 digit broker.  So adding that to the four digit price would give five digits and might cause an error.   Is it typical to just limit the tp or sl on a five digit broker to a multiple of 10 and truncate or round that extra digit off?
  1. You have to adjust for 4/5 digit brokers Pips to points so your original SL of 12.5 Pips becomes 125 points on a 5 and 12.5 points on a four. 
  2. You don't need to normalize price, except for pending order open price.
Reason: