whitmark
11-09-2007, 09:30 AM
I am testing out the advanced order functionality that is similar to what is listed in the help facility for the OnOrderUpdate method as well as the related reference example Josh posted:
private IOrder entryOrder = null;
protected override void OnBarUpdate()
{
if (entryOrder == null && Close[0] > Open[0])
entryOrder = EnterLong();
}
protected override void OnOrderUpdate(IOrder order)
{
if (entryOrder != null && entryOrder.Token == order.Token)
{
Print(order.ToString());
if (order.OrderState == OrderState.Filled)
entryOrder = null;
}
}
except that I am looking to place orders in BarsInProgressIndex = 1 vs 0 by replacing the entry logic with:
if (BarsInProgress == 1)
{
if (entryOrder == null && Close[0] > Open[0])
entryOrder = EnterLong(1, true, myOrderQty, Close[0], "myEntry");
}
Are there any special considerations to handle BarsInProgress = 1 orders when using the OnOrderUpdate method? I have been getting "Object reference not set to an instance of an object" run-tim errors when I attempt to do this.
Thanks,
Whitmark
private IOrder entryOrder = null;
protected override void OnBarUpdate()
{
if (entryOrder == null && Close[0] > Open[0])
entryOrder = EnterLong();
}
protected override void OnOrderUpdate(IOrder order)
{
if (entryOrder != null && entryOrder.Token == order.Token)
{
Print(order.ToString());
if (order.OrderState == OrderState.Filled)
entryOrder = null;
}
}
except that I am looking to place orders in BarsInProgressIndex = 1 vs 0 by replacing the entry logic with:
if (BarsInProgress == 1)
{
if (entryOrder == null && Close[0] > Open[0])
entryOrder = EnterLong(1, true, myOrderQty, Close[0], "myEntry");
}
Are there any special considerations to handle BarsInProgress = 1 orders when using the OnOrderUpdate method? I have been getting "Object reference not set to an instance of an object" run-tim errors when I attempt to do this.
Thanks,
Whitmark