how to round TP and SL to fixed number of decimals
how to round TP and SL to fixed number of decimals
15 Feb 2017, 11:33
How can I round my TP and SL targets when I send an order to a certain number of decimals depending on the currency pair? I had an order rejected as per log below because of the long decimals on TP and SL.
Limit order to Buy NZD 84k NZDJPY (Price: 81.903, SL: 48.1499999999997, TP: 6.34999999999997) is REJECTED with error "INVALID_REQUEST"
For example for NZDJPY I want to round TP and SL to 3 decimals.
Thanks
Replies
mindbreaker
15 Feb 2017, 12:20
API guide:
/api/guides/trading_api#el6
I think SL and TP is in Pips
/api/reference/robot/placelimitorder
public TradeResult PlaceLimitOrder(TradeType tradeType, Symbol symbol, long volume, double targetPrice, string label, double? stopLossPips, double? takeProfitPips)
@mindbreaker
mindbreaker
15 Feb 2017, 12:24
// SL 50 Pips TP 200 Pips PlaceStopOrder(TradeType.Buy, Symbol, Volume, Symbol.Bid + (75 * Symbol.PipSize), label, SL, TP);
@mindbreaker
mindbreaker
15 Feb 2017, 12:26
See my cBots examples for help:
https://github.com/breakermind/cAlgoRobotsIndicators
@mindbreaker
mindbreaker
15 Feb 2017, 12:13
RE:
bernd said:
Search in google: C# round
and first pahe from microsoft show what you need (its only C# )
@mindbreaker