• 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

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 Vincere, Today, 04:38 AM
              0 responses
              2 views
              0 likes
              Last Post Vincere
              by Vincere
               
              Started by trader_rick, Today, 04:02 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_ChrisSch  
              Started by percma, Today, 02:51 AM
              0 responses
              5 views
              0 likes
              Last Post percma
              by percma
               
              Started by Abilene, Today, 01:27 AM
              0 responses
              15 views
              0 likes
              Last Post Abilene
              by Abilene
               
              Started by simjs, Yesterday, 08:11 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_ChrisSch  
              Working...
              X