Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there a reason why OnMarketDepth is not being called?

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

    Is there a reason why OnMarketDepth is not being called?

    I've tried this on three machines... all installed with NT7 connected to the same IB connection.

    Only one machine seems to get the OnMarketDepth() call, the other two do not. The strategy code is identical for all 3, as well as the strategy parameters.

    Is there some setting somewhere that prevents/enables this function to be called?

    Note: bringing up the market level II window works fine on all three machines.
    Jeremytang
    NinjaTrader Ecosystem Vendor - Shark Indicators

    #2
    Hello Jeremytang,

    I can't think of any reason why OnMarketDepth() call works differently depending on the machine, when all other factors are equal.

    Same instrument, same session template, etc.

    What are you using to confirm it's called? A simple print statement should work.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Yes I'm using a print statement... it's very fickle, I just got it working on a second machine, without changing anything; It was also working on the last machine this morning, and now it's not.

      I wish there was some way to force it being called. It seems to me it gets called when it somehow sees an override of the MarketDepth method, is that the case?

      Jeremy
      Jeremytang
      NinjaTrader Ecosystem Vendor - Shark Indicators

      Comment


        #4
        It's called with any change in level II data, which can be frequent or not depending on the market you're looking at and current activity. Correct - you'll need to override the method to verify. Do you have something like this in your strategy?

        protected override void OnMarketDepth(MarketDepthEventArgs e)
        {
        Print("OnMarketDepth Called");
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Yes basically that's what I have... I'm looking at ES, YN, YB market level II which is very active...

          Is there a way to force it to recognize that it needs to call the method?
          Jeremytang
          NinjaTrader Ecosystem Vendor - Shark Indicators

          Comment


            #6
            It's only called during changes to level II handler, so there's no way to force it outside of this event.

            To track this down:
            Check log tab of control center for any error messages.
            Simplify your code so you're only using the snippet posted earlier to verify it's called. If everything works properly, then there's likely an issue with the custom code you're using.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              I must say this is rather frustating... I've just confirmed that it's not the code. I've created a brand new strategy. The only method I've implemented is this:

              protected override void OnMarketDepth(MarketDepthEventArgs e)
              {
              Print(e.ToString());
              }

              Works just fine on the computers that were running it fine before, and again doesn't work on the third computer. I've tried switching everything to the simulated accounts, switching to the free trial serial, connecting to both the paper traded IB and real trading IB accounts - same instruments, timeframe each time. Same result.

              Nothing in the log either other than the standard: Enabling strategy message
              Jeremytang
              NinjaTrader Ecosystem Vendor - Shark Indicators

              Comment


                #8
                This is weird... I suddenly got it working - again didn't do anything except maybe restarted the strategy (probably for the 20th time today). I don't know what caused it not to work, but it must be some bug preventing it from working.
                Jeremytang
                NinjaTrader Ecosystem Vendor - Shark Indicators

                Comment


                  #9
                  Jeremytang,

                  What session template are you using? Please open a T&S window of the same instrument on the side and see what you get off of that as well.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I was using the rth template, but switched it to eth (on all machines) to continue testing on all the machines once the regular trading hours were finished.
                    Jeremytang
                    NinjaTrader Ecosystem Vendor - Shark Indicators

                    Comment


                      #11
                      Are you still having issues with this? Can you pull up a level II screen or Superdom window to verify you're getting market depth at the same time you're trying to print from this method?

                      I can try with your script on my end to help eliminate code as possibility.
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      672 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      379 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      111 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      575 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      582 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X