OnAccountItemUpdate()

View as Markdown

Definition

An event driven method used for strategies which is called for each AccountItem update for the account on which the strategy is running.

OnAccountItemUpdate() will be called continually in real-time if a position exists on the account on which the strategy is running. This is to provide updates on the current Unrealized Profit and Loss and associated risk values.

Method Return Value

This method does not return a value.

Syntax

You must override the method in your strategy with the following syntax:

protected override void OnAccountItemUpdate(Account account, AccountItem accountItem, double value)

Method Parameters

ParameterDescription
accountThe Account updated
accountItemThe AccountItem updated
valueThe value of the AccountItem updated

Examples

1protected override void OnAccountItemUpdate(Account account, AccountItem accountItem, double value)
2{
3 Print(string.Format("{0} {1} {2}", account.Name, accountItem, value));
4
5 // output:
6 // Sim101 BuyingPower 103962.5
7 // Sim101 CashValue 103962.5
8 // Sim101 GrossRealizedProfitLoss 3962.5
9 // Sim101 RealizedProfitLoss 3962.5
10}