I created a separate strategy that is nothing but account update.
I write to a file the current Pnl as it changes. So I have a strategy but I guess it could be an indicator. I want to record a certain account with the pnl. I have everything for creating the file. Thats all working, But I would rather just update when PnL changed.
I get a file updated but there is no current Pnl from the account the strategy is added to. When I add the strategy for account update it , the account already has a current PnL but it shows 0 in the file that's getting updated. So what is proper code to get the current account info?
Here is the code snippet:
protected override void OnBarUpdate()
{
PnLUpdate();
}
private void PnLUpdate()
{
PnL_unrealized = Math.Round(Position.GetUnrealizedProfitLoss(Perfor manceUnit.Currency),2);
PnL_realized = Math.Round(SystemPerformance.RealTimeTrades.Trades Performance.Currency.CumProfit,2);
accountDetails = PnL_unrealized.ToString("N2") + ";" + PnL_realized.ToString("N2") + ";" + DailyProfitLimit.ToString("N2") + ";" + DailyLossLimit.ToString("N2");
File.WriteAllText(path,accountDetails);
}
Comment