Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Fill time on multiple dataseries strategy

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

    Fill time on multiple dataseries strategy

    Hi guys,
    a strategy that loads additional bar series is experiencing knowing about fills before they can happen. Attached is a picture which shows a stop entry order Long at 101.89, placed at the time of the close of the 2:00AM bar, fills during the bar that closes at 2:10AM.
    Unfortunately Ninja advises of this fill in advance, at 2:05. This screws up some other logic in the strategy to do with entry order cancellation on a bar against the trade direction (note the red bar of 2:05AM).
    If, at the time of the close of the bar at 2:05 the strategy knew it had had a red bar, it would have cancelled the long entry order and never been filled. Unfortunately at 2:05 there is a fill erroneously advised.

    See this excerpt from OutputWindow text. Note the fill at 2:05AM. I am catching Executions in OnExecution() and placing stop and target orders there.

    msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM Placing order to enter Long on AAPL at 101.89 size 49
    7/01/2016 2:00:00 AM Entered internal SubmitOrder() method at 7/01/2016 2:00:00 AM: Action=Buy OrderType=Stop Quantity=49 LimitPrice=0 StopPrice=101.89 OcoId='a7947ad2457c40e8a7a1165c8c6be650' Name='LE_AAPL_msStockGroupBreakoutsV2'
    msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00007/Backtest' Name='SE_AAPL_msStockGroupBreakoutsV2' State=PendingCancel Instrument='AAPL' Action=SellShort Limit price=0 Stop price=100.2 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='294e4b123e074631b7c889c744bb176b' Filled=0 Fill price=0 Token='0fcef0bbb95e4448bae5f0770d74c377' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00007/Backtest' Name='SE_AAPL_msStockGroupBreakoutsV2' State=Cancelled Instrument='AAPL' Action=SellShort Limit price=0 Stop price=100.2 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='294e4b123e074631b7c889c744bb176b' Filled=0 Fill price=0 Token='0fcef0bbb95e4448bae5f0770d74c377' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=PendingSubmit Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=0 Fill price=0 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=Accepted Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=0 Fill price=0 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=Working Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=0 Fill price=0 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=Filled Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=49 Fill price=101.89 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnExecution(): Execution='NT-00004' Instrument='AAPL' Account='Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' Exchange=Default Price=101.89 Quantity=49 Market position=Long Commission=0 Order='NT-00008' Time='7/01/2016 2:10:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM Placing initial stop for Long trade LE_AAPL_msStockGroupBreakoutsV2 at 100.38
    7/01/2016 2:05:00 AM Entered internal SubmitOrder() method at 7/01/2016 2:05:00 AM: Action=Sell OrderType=Stop Quantity=49 LimitPrice=0 StopPrice=100.38 OcoId='' Name='LS_AAPL_msStockGroupBreakoutsV2'
    msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00009/Backtest' Name='LS_AAPL_msStockGroupBreakoutsV2' State=PendingSubmit Instrument='AAPL' Action=Sell Limit price=0 Stop price=100.38 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='036ecacad50d41f385ff3e184f7afde8' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00009/Backtest' Name='LS_AAPL_msStockGroupBreakoutsV2' State=Accepted Instrument='AAPL' Action=Sell Limit price=0 Stop price=100.38 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='036ecacad50d41f385ff3e184f7afde8' Gtd='1/12/2099 12:00:00 AM'
    msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00009/Backtest' Name='LS_AAPL_msStockGroupBreakoutsV2' State=Working Instrument='AAPL' Action=Sell Limit price=0 Stop price=100.38 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='036ecacad50d41f385ff3e184f7afde8' Gtd='1/12/2099 12:00:00 AM'
    Please note that the trade will work correctly if no additional bar series are loaded. It fails only when additional bar series are loaded. The strategy code, methinks, is not the problem. It is the fill event out of Ninja being early and seeing into the future.

    This is NT7 v31.

    Please advise,
    saltminer
    Attached Files
    Last edited by saltminer; 02-04-2016, 04:49 PM.

    #2
    Hello saltminer,

    Thank you for your post.

    To get a better understanding of what you are seeing please answer the following questions.

    Are you running a backtest when you see this? Is this fill on the secondary bar series?
    Or is this in Real-Time or Market Replay? If so, are you running CalculateOnBarClose equals True or False?

    Comment


      #3
      It is historical bars on a normal chart. The fill is on a secondary bar series.
      saltminer

      Comment


        #4
        Hello,

        Thank you for the reply.

        I wanted to check, based on your description this sounds like the logic is being executed for both series, are you currently checking which BarsInProgress the events are being called in?

        Based on the description, this could happen if you were using a 10 minute chart and have a 5 minute secondary series as an example. In the case the 5 minute series updates before the 10 which it should, you would see the order "early" or submitted from the 5 minute series. Is this the case?

        If you could provide a sample showing the logic being used for the orders it may provide more information on what is happening.

        Please let me now if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        11 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        7 views
        0 likes
        Last Post elirion
        by elirion
         
        Working...
        X