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

MarketData objects and after hours

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

    MarketData objects and after hours

    What is the expected behavior of MarketData objects and the Update event if it is used outside of the session for the instrument?

    I am using a MarketData object to obtain market data for an instrument. If the calls are made during hours for which the instrument is in session the callback is called. After hours it is called for some instruments but not others with no discernible reason as to why.

    Code:
    var marketData = new MarketData(instrument);
    marketData.Update += (sender, e) => { /* do some stuff with market data */ };
    The above code provided to make it clear what I am using. Generally the Update event is triggered relatively fast but in some cases even after 10 or more minutes its never called. The various values in the MarketData object are also never filled in.

    A data connection is confirmed as connected before calls are made.

    #2
    Hello ntbone,

    Thanks for your post.

    What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)

    Who are you connected to? This is displayed in green on the lower-left corner of the Control Center window.

    I see you mention this behavior only occurs for some instruments. What instrument symbol (and expiry if applicable) are you testing when you see this behavior occur?

    If possible, could you please provide us with a simple test script that reproduces the behavior you are reporting and the exact steps/settings you are using to reproduce the behavior so that we may investigate this matter further?

    I look forward to assisting further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      I am using NinjaTrader 8.0.28.0

      I am using Kinetick connection and yes, it is connected during all the testing.

      All the instruments I am using on US stocks on either the Nasdaq or NYSE exchanges.

      I spent a bunch of time trying to narrow down the issue to the smallest scenario that still reproduces the problem but do not have anything small enough that I can share.

      The smallest workspace that reproduces the problem has
      • A single 1 minute chart with 20 days of data
      • 3 symbols in a Market Watch window
      • 3 Tabs in a Market Analyzer. One has 95 symbols in it, one has 4 and one is empty.
      Once an instrument is in a state where it won't call the Update event, it seems to be stuck in that state, no matter how many times I call the code to query for market data. I am unsubscribing from the event after it is no longer needed. It seems that having a demand on Market data combined with it being after hours is important to the reproduction. The demand here doesn't seem to be anything unreasonable. My Kinetick feed is upgraded to support 500 symbols. The issues are never a problem during regular market hours.

      The expected behavior of MarketData would be to load the last price for an instrument if it is after hours?

      Comment


        #4
        Hello ntbone,

        Thanks for your notes.

        To investigate this behavior further, we will need to be able to consistently reproduce the behavior using a simple test script and the steps used to encounter the behavior. With this information we could try reproducing the behavior on our end to look into the possible cause of the behavior.

        Are you creating a custom NinjaScript AddOn, Indicator, or Strategy in the NinjaScript Editor?

        Do you see the behavior for a specific instrument? If so, which instrument do you see the behavior occur for?

        What is the instrument the 1-minute chart is set to use?

        What are the three symbols in the Market Watch window that you mentioned?

        How are you accessing the instrument price value? Are you printing the information within OnMarketData() or are you printing the information from say an AddOnTab as seen in the MarketData help guide page?

        MarketData: https://ninjatrader.com/support/help...marketdata.htm

        Please try to note what instrument you see the behavior occurring for and create a simple test script that reproduces the behavior. Once you are able to reproduce the behavior, please send us the simple test script and the steps you used to reproduce the behavior so that we may further investigate this matter.

        I look forward to assisting further.
        Last edited by NinjaTrader_BrandonH; 09-24-2023, 05:12 PM.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I understand about reproduction and have been trying to narrow down the problem to the smallest amount of code and situation that I can reproduce.
          The code I am working on is called from an Indicator but as I demonstrated with the sample code I am using the "MarketData" object to get the market data. Based on documentation

          Code:
          var marketData = new MarketData(instrumentOfInterest);
          marketData.Update += updateHandler; //whatever the update handler will be
          
          // once the update handler has been called at least once one can then get the price via marketData.Last.Last.
          // marketData.Last is null until the handler is called.
          During market hours the update handler is always called for instruments. After hours, the handler is called for some instruments and not others. There's no discernable pattern to which ones it works for and which ones it does not.

          I have taken a workspace that has the issue and been removing as much from it as possible while still being able to reproduce the problem. As I mentioned before the smallest workspace that reproduces the problem as a
          • 1 minute chart with 20 days of data. A few moving average indicators and the indicator that I custom wrote that queries for the price via MarketData object.
          • A market analyzer window with 3 taps, one which has 95 symbols in it. A few other tabs also seem important though its clear why as they have almost nothing in them.
          • The MarketWatch window with the SPY, QQQ and DIA in it.
          From what I now understand, the MarketData object should be calling the event handler.

          Comment


            #6
            Hello ntbone,

            Thanks for your notes.

            To investigate this matter further we would need the specific details of how to consistently reproduce the behavior and a simple test script that demonstrates the behavior so that we could try reproducing the behavior on our end, investigate the reproduced behavior, and explain if the behavior is expected or not.

            Please try to create a simple test script and narrow down the specific details to consistently reproduce the behavior. Once you have narrowed it down and are able to reproduce the behavior using a simple test script, please share the script and the exact steps and settings you use to reproduce the behavior and we will be happy to investigate further.

            That said, keep in mind that most instruments will not have much or any change at all after hours depending on the popularity of the instrument, so that could also factor in to the behavior you are seeing.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              I now have reproduction steps that use tests using a small addon, a workspace using only installation included Indicators and Windows. I can provide the reproduction steps as to produce the problem.

              For those reading this thread there are several potential elements about this workspace that are important.
              1. A market analyzer is included with about 28 symbols in it.
              2. The market analyzer has columns that are indicators.
              I can email support with workspace and addon. Please let me know how to connect the email to this thread.
              Last edited by ntbone; 09-26-2023, 12:47 AM.

              Comment


                #8
                Hello ntbone,

                Thanks for your notes.

                If you are able to consistently reproduce the behavior using a simple reduced test script and specific steps, please send the simple reduced exported test script and the exact steps and settings to reproduce the behavior to support[at]ninjatrader[dot]com so we may try to reproduce the behavior on our end using the test script and steps/settings you provide.

                In the subject of the email include 'Attn: BrandonH' and in the body of the email include a link to this forum thread.

                Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed..

                To export the reduced test script, go to Tools > Export > NinjaScript AddOn.​

                We look forward to assisting further.
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jasonweil, Today, 04:06 AM
                0 responses
                6 views
                0 likes
                Last Post jasonweil  
                Started by alishashanion, Today, 04:01 AM
                0 responses
                7 views
                0 likes
                Last Post alishashanion  
                Started by carnitron, 10-26-2023, 02:28 PM
                6 responses
                191 views
                3 likes
                Last Post davydhnz  
                Started by redneyany, Today, 03:12 AM
                0 responses
                8 views
                0 likes
                Last Post redneyany  
                Started by Nevauydriguez, Today, 02:58 AM
                0 responses
                9 views
                0 likes
                Last Post Nevauydriguez  
                Working...
                X