Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing MarketDepth Data

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

    Accessing MarketDepth Data

    I'm trying to develop an indicator that will pull the marketdepth volume for bid and asks then perform a simple calculation, but I cannot seem to find the right syntax to do it. When i try to compile it I get the following error

    Using the generic type 'NinjaTrader.Data.MarketDepth<T>' requires 1 type arguments
    This is the code I thought would work:

    Code:
    protected override void OnMarketDepth(MarketDepthEventArgs e)
    {
    for (int i = 0; i < 5; i++)
    {
    bidvol = MarketDepth.Asks[i].Volume;
    askvol = MarketDepth.Bids[i].Volume;
    }
    
    balance = bidvol/askvol;
    }
    Any help would be great. Thank you.

    #2
    Hello maxwellspi,

    Thank you for your post.

    I'd suggest taking a look at the example from our help guide of building your own Level 2 book:



    The incoming event being processed should be checked whether it is an ask or bid event. You can check whether it's an ask or bid event with:

    Code:
    if (e.MarketDataType == MarketDataType.Ask)
    {
         //do something
    }
    
    if (e.MarketDataType == MarketDataType.Bid)
    {
         //do something
    }
    That example linked above shows assigning the values to a list, but you could use a different method to hold the prices if you like.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      The example you provided helped! Thank you NinjaTrader_Kate

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      156 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      90 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      140 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      130 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X