I'm using Last PnL and Last Profit in an auto strategy. The code lines are
lastProfit = (lastTrade.ProfitCurrency * contracts) ; and
lastpnl = (Performance.AllTrades.TradesPerformance.Currency. CumProfit - priorTradesCumProfit);
The output window returns:
The Last PnL is -84.6999999999983
The Last Profit is -84.6999999999983
I changed the code lines to read:
lastProfit = Math.Round(lastTrade.ProfitCurrency * contracts) ; and
lastpnl = Math.Round(Performance.AllTrades.TradesPerformance .Currency.CumProfit - priorTradesCumProfit);
This successfully rounded to the nearest whole number, but I need it rounded to 2 decimals.
I tried to use the "pop up" menu example of
decimal Math.Round(decimal d, int decimals, midpointrounding mode)
but I get a best overload error and cannot convert from double to system midpointrounding error. It wants a current bar [0] of some sort and seems to be applicable to indicators.
Can someone tell me how to make the Math.Round round the Last PnL and Last Profit to 2 decimal places?
Thanks!
Joe
Comment