However, when running in Strategy Analyzer, Account.Orders stays empty.
This happens while running managed and unmanaged orders.
1. Is this as designed? I cannot find this restriction documented anywhere.
2. Is there any way for a strategy running in Strategy Analyzer to access to the collection of orders?
thanks, in anticipation.
Ralph
Here is my test code, running in a new simple strategy builder created strategy
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Generate orders - If it is a Tick - go long, if a Tock - go short
if (CurrentBar % 2 == 0) // Tick
EnterLong(Convert.ToInt32(DefaultQuantity), @"EnterLong");
else // Tock
EnterShort(Convert.ToInt32(DefaultQuantity), @"EnterShort");
// Code to display the no orders collected for all accounts.
Print(String.Format("NinjaTrader.Cbi.Account.All.C ount={0}", NinjaTrader.Cbi.Account.All.Count));
foreach (Account TheAccount in NinjaTrader.Cbi.Account.All)
{
Print(String.Format("TheAccount.Name={0}. TheAccount.Orders.Count={1}.", TheAccount.Name, TheAccount.Orders.Count));
foreach (Order ThisOrder in TheAccount.Orders)
{
Print(String.Format("ThisOrder.Name={0}. ThisOrder.ThisOrder={1}.", ThisOrder.Name, ThisOrder.OrderState));
}
}
// Alternate code demonstrating the problem using the "Account"
//Print(String.Format("Account.Name={0}", Account.Name));
//Print(String.Format("Account.Orders.Count={0}.", Account.Orders.Count));
//foreach (Order ThisOrder in Account.Orders)
//{
// Print(String.Format("ThisOrder.Name={0}. ThisOrder.ThisOrder={1}.", ThisOrder.Name, ThisOrder.OrderState));
//}
}
Comment