Attached is a behavior that is hopefully a bug (will get fixed) and not a feature(will not get fixed). Basically, I run my strategy on a 1 minute chart with some inputs from the 5 min chart of the same instrument.
When the strategy is run with just a single series (primary series is 1 min as I run it from a 1 min chart), EnterLongLimit and EnterShortLimit work as expected. They hang around for the entire period of the 1 min bar and if not filled during that time, they get cancelled at the beginning of the next bar. When an additional series is added to the strategy, the bar updates on the second series cause the Limit orders from the primary series to be cancelled immediately.
Expected behavior is that regardless of updates to the secondary series in the strategy, the Limit orders created in the primary series retain their original behavior (live till the end of the period of the primary bar). Version of NinjaTrader is 7.0.1000.8
If there is another mechanism to enable the expected behavior, I would be obliged. I know about turning the flag on to let the order be till cancelled which is not what I want to do - babysit orders.
Enclosed is the code. The first script runs as intended and the order gets executed about 40 seconds after submission. In the second, we can see the cancellation immediately.
protected override void Initialize()
{
TraceOrders = true;
ClearOutputWindow();
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0) //<== The bar index 0 is for 1 min bars
return;
if (Historical)
return;
if (!FirstTickOfBar)
return;
if (Position.Quantity == 0 && Position.MarketPosition == MarketPosition.Flat)
{
EnterShortLimit(1, Close[1]+TickSize, "Short");
}
}
protected override void OnExecution(IExecution execution)
{
Print(execution.ToString());
}
**NT** Enabling NinjaScript strategy 'Test/f0f42cc6360b448589598f8aef78c949' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=UniqueEntries EntriesPerDirection=3 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
11/23/2011 1:18:01 AM Entered internal PlaceOrder() method at 11/23/2011 1:18:01 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1172.25 StopPrice=0 SignalName='Short' FromEntrySignal=''
Execution='865ee9298a244d6ab1ec085ed2766460' Instrument='ES 12-11' Account='Replay101' Name='Short' Exchange=Default Price=1172.25 Quantity=1 Market position=Short Commission=0 Order='734f048f1ba34512a760014ad5b6befc' Time='11/23/2011 1:18:49 AM'
------------------------------------------------------------------------------
protected override void Initialize()
{
Add(PeriodType.Minute, 5); // <== This is the only difference between the two strategies.
TraceOrders = true;
ClearOutputWindow();
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0) //<== The bar index 0 is for 1 min bars
return;
if (Historical)
return;
if (!FirstTickOfBar)
return;
if (Position.Quantity == 0 && Position.MarketPosition == MarketPosition.Flat)
{
EnterShortLimit(1, Close[1]+TickSize, "Short");
}
}
protected override void OnExecution(IExecution execution)
{
Print(execution.ToString());
}
**NT** Enabling NinjaScript strategy 'Test/f0f42cc6360b448589598f8aef78c949' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=UniqueEntries EntriesPerDirection=3 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
11/23/2011 1:18:01 AM Entered internal PlaceOrder() method at 11/23/2011 1:18:01 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1172.25 StopPrice=0 SignalName='Short' FromEntrySignal=''
11/23/2011 1:18:01 AM Cancelled expired order: BarsInProgress=1: Order='04a6d149f25748999eedff3202163e77/Replay101' Name='Short' State=Working Instrument='ES 12-11' Action=SellShort Limit price=1172.25 Stop price=0 Quantity=1 Strategy='Test' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='04a6d149f25748999eedff3202163e77' Gtd='12/1/2099 12:00:00 AM'
-----------------------------------------------------------------------------------------------------
Thanks for your time.
PR
Comment