• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Cancelled expired order" unexpected behavior

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    "Cancelled expired order" unexpected behavior

    Hello,

    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

    #2
    Hello,

    Thanks for the forum post and welcome to the forums.

    Unfortunately this is expected with current infrastructure design when the instrument is the same as the primary(or instrument/dataSeries the order was originally submitted on).

    Development is aware of the desire to allow this and are looking into this area to possibly make a change in the next major version of NinjaTrader. This is still some time out from release however.

    -Brett
    BrettNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by HiddenPhilosopher, Yesterday, 11:58 PM
    0 responses
    1 view
    0 likes
    Last Post HiddenPhilosopher  
    Started by glennts, Yesterday, 08:24 PM
    2 responses
    12 views
    0 likes
    Last Post bltdavid  
    Started by ibabinov, 11-12-2019, 09:50 AM
    3 responses
    66 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by PrimoItch, 05-27-2020, 04:35 PM
    2 responses
    18 views
    0 likes
    Last Post bkonia
    by bkonia
     
    Started by RuthB, 05-29-2020, 09:41 PM
    2 responses
    19 views
    0 likes
    Last Post RuthB
    by RuthB
     
    Working...
    X