Is it possible run a strategy using the OnBarUpdate method as well as the OnMarketData method at the same time. I'd like to have my strategy conditions run in the OnBarUpdate section and then once an order is placed I will have a condition in the OnMarketData section checking to see if an order is working and modify IOrders based on Market changes. I'm able get this to compile but running it in market replay it produces the log error. "Object reference not set to an instance of an object. It looks something like this:
protected override void OnBarUpdate()
{
// Condition set 1
if ( myOrderShort == null && Close[0] > Open[0] )
{
DrawArrowDown(CurrentBar.ToString(), true, 0, Close[0], Color.Red);
myOrderShort = EnterShortLimit(0, true, ent,GetCurrentAsk(),"SHORT LIMIT 1");
}
}
protected override void OnMarketData (MarketDataEventArgs e)
{
{
if(myOrderShort == null && myOrderShort.OrderState == OrderState.Working && e.marketDataType == MarketDataType.Ask)
EnterShortLimit(0, true, ent,GetCurrentAsk(),"SHORT LIMIT 1");
}
}

Comment