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

Unexpected behavior of OnOrderUpdate() calls with Intrabar data

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

    Unexpected behavior of OnOrderUpdate() calls with Intrabar data

    Hi,
    Although I am using Intrabar data (1Min), the OnOrderUpdate() was always called on the main time frame (60Min)

    Here are the specifics:
    Instrument: ES ##-##
    Main Time Frame = 60 Min
    Secondary Time Frame = 1 Min
    Bar in question was on 11/16/2012 at 11:30 AM
    The Buy order was filled at 1350.75 at time 11:30AM
    The Profit target was filled at 1354.75 at time 11:30AM
    Looking at the 1Min Chart, I see that the 1354.75 level was not touched until 12:16PM

    So, it looks like the OnOrderUpdate() is called only on the 60Min time frame.

    I printed 'Time[0]' at the beginning of OnOrderUpdate(). Here are the fills of the Buy and the Profit Target:
    OnOrderUpdate Time: 11/16/2012 11:30:00 AM
    IOrder Order='NT-00081/Sim101' Name='Buy' State=Filled Instrument='ES ##-##' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='RKMTest' Type=Market Tif=Gtc Oco='' Filled=1 Fill price\
    =1350.75 Token='27ebb46b1e1f48589cfab756b19f1d66' Gtd='12/1/2099 12:00:00 AM'

    OnOrderUpdate Time: 11/16/2012 11:30:00 AM
    IOrder Order='NT-00083/Sim101' Name='Profit target' State=Filled Instrument='ES ##-##' Action=Sell Limit price=1354.75 Stop price=0 Quantity=1 Strategy='RKMTest' Type=Limit Tif=Gtc Oco='NT-00\
    050-4323' Filled=1 Fill price=1354.75 Token='8ce78dd643fc489093af083bda429056' Gtd='12/1/2099 12:00:00 AM'

    The Code for the strategy is attached.

    Thanks,
    Robert.
    Attached Files

    #2
    Hello Robert,

    That is because the order was placed on the 60 Minute time frame or the BarsInProgress = 0 value. If you would like an intrabar fill you may view the following thread that has a reference sample that you may download.

    http://www.ninjatrader.com/support/f...ead.php?t=6652

    Let us know if we can be of further assistance.
    Last edited by NinjaTrader_JC; 11-19-2012, 03:24 PM.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,
      How do I get a login to the ninjatrader-helpdesk.com to view the reference sample you indicated?

      Thanks.

      Comment


        #4
        Hello rkm2011,

        I apologize for the incorrect link, it is a reference sample from our Support Forums. I have changed the link and will post it again below.

        http://www.ninjatrader.com/support/forum/showthread.php?t=6652
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,
          Thanks for the link.
          I have corrected the code to enter on secondary time frame:
          EnterLong(1, DefaultQuantity, "");

          But the result is still the same as before.
          The new code is attached.
          Attached Files

          Comment


            #6
            Hello Robert,

            Using Market order you typically will not need intrabar fills as they will be filled. Could you clarify what you are expecting to happen and what is actually happening?

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              JC,
              If you go back to my original post, you'll see that the problem is with the Profit Target (which
              is a stop limit order; not a market order) where it seems to be filled on the 60Min time frame.
              I expect NT to evaluate it on 1Min time frame. So in this example, I expect NT to call
              OnOrderUpdate() at time 12:16PM (or later). I thought this the whole point of specifying the 1Min
              data series. Did I misunderstand the intent of intrabar?

              The code I attached is a toy example. I am trying to understand the behavior of this intrabar data
              because I am seeing similar unexpected behavior in my actual strategy.

              Thanks.

              Comment


                #8
                Robert, thanks for the clarification - if you're using the Set methods they would always be evaluated on the primary series - so would not use the 1 min you added in here in your script. To be able to pass the stops / targets to a finer series for more accuate backesting, please use the Exit methods which offer a dedicated BarsInProgress parameter to submit against.



                All the best,
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Uregon, Today, 03:44 AM
                0 responses
                2 views
                0 likes
                Last Post Uregon
                by Uregon
                 
                Started by CyberNate, 11-17-2020, 08:15 PM
                2 responses
                426 views
                0 likes
                Last Post nurpalgo  
                Started by sdauteuil, 09-23-2021, 10:16 AM
                7 responses
                1,247 views
                0 likes
                Last Post marcus2300  
                Started by sofortune, 05-18-2024, 11:48 AM
                2 responses
                34 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by Zach55, 02-19-2024, 07:22 PM
                2 responses
                67 views
                0 likes
                Last Post lbadisa1  
                Working...
                X