Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Check if level 2 data is available

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

    Check if level 2 data is available

    Hi,

    is it possible to check in an indicator, if level 2 data (marketdepth) is available for an instrument or connection.
    This information would be needed to enable or disable a new feature of the indicator.

    Thanks in advance!
    Armin

    #2
    Hello Armin,

    There is not a method or property that would state if level 2 data is subscribed.

    It would be necessary to use a variable that starts as -1 or null and is assigned on the first update of OnMarketDepth() to see if this is running.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      thanks for your answer!

      When I add the OnMarketDepth to the indicator, I get an get_order_book error in the Log.
      Will that cause any problems/restrictions to the indicator or will it run without limitations?

      Best regards,
      Armin

      Comment


        #4
        Hello Armin,

        Unfortunately, I am uncertain. You can test by adding a print to OnMarketData() and see if the print is appearing in real-time after the error appears.



        May I have the full error message to further investigate?

        Ctrl + c to copy the line on the log, Ctrl + v to paste.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          I've added this part of code to a small test indicator.
          protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate)
          {
          Print(DateTime.Now + " OnMarketDepth " + marketDepthUpdate.ToString());
          }

          protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
          {
          Print(DateTime.Now + " OnMarketData " + marketDataUpdate.ToString());
          }

          ​That will result in the following error in the Log tab:
          06.04.2023 17:26:57 Connection Market data failed for 'ES 06-23': 'get_order_book error : 13'

          The OnMarketDepth is not triggered, but the OnMarketData fills the Output with a huge amount of new lines like these:
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Ask price=4115,25 volume=97 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=46 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=47 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=48 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=47 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=46 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=47 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=48 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:54 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=49 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=51 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=53 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=52 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=53 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=55 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=56 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Ask price=4115,25 volume=81 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False
          06.04.2023 17:37:55 OnMarketData instrument='ES 06-23 Globex' type=Bid price=4115 volume=54 time='06.04.2023 17:37:54' bid=4115 ask=4115,25 isReset=False



          Does it mean that I can rely that the indicator will work properly without any restrictions?

          Thanks a lot for your support!
          Armin

          Comment


            #6
            Hello Armin,

            Yes, the indicator is still running as confirmed by these prints.

            As long as OnMarketDepth does not update, this would imply that level 2 is not available.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X