#region Method-OnAccountItemUpdate
protected override void OnAccountItemUpdate(Cbi.Account account, Cbi.AccountItem accountItem, double value)
{
// Updated Account P&L
AccountRealizedPL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
AccountUnrealizedPL = account.Get(AccountItem.UnrealizedProfitLoss, Currency.UsDollar);
DailyAccountPNL=Math.Round(AccountRealizedPL+Accou ntUnrealizedPL,2);
Draw.TextFixed(this, "DailyAcctPNL","\n\n\n\n\t\t" + DailyAccountPNL , TextPosition.TopLeft, Brushes.Green, new SimpleFont ("Arial",14), Brushes.Transparent, Brushes.Green, 0) }
#endregion
On the first account profit, it updates correctly by using the OnAccountItemUpdate method however for the strategy daily profit I cannot get to update correctly, it only updates when the candle closes.
protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, Cbi.MarketPosition marketPosition)
{
OpenedTrades=quantity;
DailyStrategyPNL=SystemPerformance.AllTrades.Trade sPerformance.Currency.CumProfit-PriorTradesCumProfit+Position.GetUnrealizedProfitL oss(PerformanceUnit.Currency, Close[0]);
Draw.TextFixed(this, "DailyStratPNL","\n\n\n\t\t" + DailyStrategyPNL , TextPosition.TopLeft, Brushes.Green, new SimpleFont ("Arial",14), Brushes.Transparent, Brushes.Green, 0); }
I tried onbarupdate and onpositionupdate and none of them updated correctly on each price change as the account does. what am I doing wrong?
Thanks, Marcelo
Comment