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

AddOn Subscribe Market Depth Q

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

    AddOn Subscribe Market Depth Q

    For subscribing to market depth in an AddOn, is there any real difference between creating a new MarketDepth<MarketDataRow> instance and just adding a handler to the Instrument.MarketDepthUpdate event directly?

    i.e.
    Code:
     instrument.MarketDepthUpdate += OnMarketDepth;
    
    vs
    
     marketDepth = new MarketDepth<MarketDepthRow>(instrument);
     marketDepth.Update += OnMarketDepth;
    Just trying to understand the reason for the extra indirection and if necessary. Thanks.

    #2
    Hello aslane,

    Thanks for your post.

    We do not document or suggest subscribing/unsubscribing to MarketDepthEvents directly from the instrument as this may not be safe. To be able to safely subscribe and unsubscribe, it is recommended to create the MarketDepth<MarketDepthRow> object or MarketData object for OnMarketData and then subscribe and unsubscribe to the Update events.

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Ok, that makes sense. I was asking because I am seeing some strange behavior and am trying to determine the cause.

      In my addon, I subscribe the the depth, but only rx OnMarketDepth events for the snapshot entries (20 entries for ES - 10 Bid/Ask) and no additional updates. When I do the same thing in a simple test addon, it works as expected and sends the snapshot entries and all subsequent updates.

      So what would cause the market depth subscription to only send thru the snapshot?

      I have multiple market data and bars requests all running as expected, it is only the depth that seems to have an issue. Also, the depth is running fine in DOMs etc.

      Comment


        #4
        Hello aslane,

        If you are seeing a difference between the a test script and your main script, this would most likely be a difference in how the code is used. A difference in Instruments used could explain the behavior seen or if we did not see any level 2 updates or if the NinjaScript output window has not processed the output yet. After verifying these, I would suggest then commenting out your current implementation and testing with your test script code included verbatim.

        Let me know if there is anything else I can do to help.
        JimNinjaTrader Customer Service

        Comment


          #5
          It works correctly when I add my handler to instrument.MarketDepth.Update directly, and it fails as previously stated when I create a MarketDepth and attach to that objects Update.

          Comment


            #6
            Hello aslane,

            When I add the code as directed from the help guide in an AddOn, I get the updates as I would expect. I have included a test AddOn you can use on your end.

            I look forward to being of any further assistance.
            Attached Files
            JimNinjaTrader Customer Service

            Comment


              #7
              Yes, as I originally stated, a simple example that does nothing works correctly.

              I am sure it is some ninja thread issue, but feel free to consider this closed since I found a way to tame ninja.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              6 views
              0 likes
              Last Post maybeimnotrader  
              Started by quantismo, Today, 05:13 PM
              0 responses
              6 views
              0 likes
              Last Post quantismo  
              Started by AttiM, 02-14-2024, 05:20 PM
              8 responses
              166 views
              0 likes
              Last Post jeronymite  
              Started by cre8able, Today, 04:22 PM
              0 responses
              8 views
              0 likes
              Last Post cre8able  
              Started by RichStudent, Today, 04:21 PM
              0 responses
              5 views
              0 likes
              Last Post RichStudent  
              Working...
              X