I created the following strategy that I use for verifying workflow of events.
namespace NinjaTrader.NinjaScript.Strategies
{
public class WorkflowStrategy : Strategy
{
bool realTimeAccount = false;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Overview of what events fire and items set";
Name = "Workflow";
Print("OnStateChange: SetDefaults");
}
else if (State == State.Configure)
{
Print("OnStateChange: Configure");
CheckAccount();
}
else if (State == State.Realtime)
{
Print("OnStateChange: Realtime");
realTimeAccount = true;
CheckAccount();
}
else if (State == State.Historical)
{
Print("OnStateChange: Historical");
CheckAccount();
}
else if (State == State.Active)
{
Print("OnStateChange: Active");
realTimeAccount = true;
CheckAccount();
}
else if (State == State.Transition)
{
Print("OnStateChange: Transition");
CheckAccount();
}
else if (State == State.DataLoaded)
{
Print("OnStateChange: DataLoaded");
CheckAccount();
}
else if (State == State.Terminated)
{
Print("OnStateChange: Terminated");
CheckAccount();
}
}
protected override void OnBarUpdate()
{
if (realTimeAccount) CheckAccount();
}
private void CheckAccount()
{
if (Account == null) {
Print("CheckAccount: null account");
} else {
Print("CheckAccount: CashValue:" + Account.GetAccountItem(AccountItem.CashValue, Currency.UsDollar).Value);
Print("CheckAccount: GrossRealizedProfitLoss" + Account.GetAccountItem(AccountItem.GrossRealizedProfitLoss, Currency.UsDollar).Value);
Print("CheckAccount: Commission" + Account.GetAccountItem(AccountItem.Commission, Currency.UsDollar).Value);
Print("CheckAccount: TotalCashBalance" + Account.GetAccountItem(AccountItem.TotalCashBalance, Currency.UsDollar).Value);
Print("CheckAccount: BuyingPower" + Account.GetAccountItem(AccountItem.BuyingPower, Currency.UsDollar).Value);
Print("CheckAccount: InitialMargin" + Account.GetAccountItem(AccountItem.InitialMargin, Currency.UsDollar).Value);
Print("CheckAccount: IntradayMargin" + Account.GetAccountItem(AccountItem.IntradayMargin, Currency.UsDollar).Value);
Print("CheckAccount: RealizedProfitLoss" + Account.GetAccountItem(AccountItem.RealizedProfitLoss, Currency.UsDollar).Value);
Print("CheckAccount: PositionMargin" + Account.GetAccountItem(AccountItem.PositionMargin, Currency.UsDollar).Value);
}
}
}
}
EDIT - the **** appears to not show the actual .value in the ToString(). Wish it did for debugging purpose.

Comment