I am using the following code within my strategy to generate a DataSeries of cumulative profit generated by my strategy in USD terms. I am trading Indirect Forex Rates (e.i. USDJPY) and I need this because the function provided by NT Performance.AllTrades.TradesPerformance.Currency.C umProfit would only return a profit in JPY, whilst I need to know my USD Cumulative Profit, that is simply the sum of the historical profit for each trade divided by the exit price at the time (please see lastProfit = new DataSeries below). This code works perfectly in my strategy, HOWEVER when using the Print fuction to return the value in the output window Print("CumProfit: "+ CumulativeLastProfit[0]); returns an incorrect value, basically it always returns the lastProfit[0], would you be able to indicate what I am doing wrong?
#region Variables
private DataSeries lastProfit;
private DataSeries CumulativeLastProfit;
#endregion
protected override void Initialize()
{
lastProfit = new DataSeries(this, MaximumBarsLookBack.Infinite);
CumulativeLastProfit = new DataSeries(this, MaximumBarsLookBack.Infinite);
}
protected override void OnBarUpdate()
{
lastProfit.Set(lastTrade.ProfitCurrency*lastTrade.Quantity /lastTrade.Exit.Price;
CumulativeLastProfit.Set(CumulativeLastProfit[1] + lastProfit[0]);
Print("CumProfit: "+ CumulativeLastProfit[0]);
}

Comment