Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where can the Market Detph be defined ?

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

    Where can the Market Detph be defined ?

    On your example here
    https://ninjatrader.com/support/help...vel_ii_dat.htm

    The following statement is used:

    for (int idx = 0; idx < askRows.Count; idx++)
    Print("Ask Price=" + askRows[idx].Price + " Volume=" + askRows[idx].Volume + " Position=" + idx);

    According to my understanding "askRows.Count" represents the market depth on the ask side of the limit order book provided by the data feed, e.g. Rithmic.
    I further understand, that idX = 0 represents the best ask price and higher numbers represent the ask prices in the limit orderbook further away from best ask.

    Is that understanding correct ?

    1st Question:
    Is it possible to limit this depth, so that askRows.Count only represents a number predefined by myself (similar to setting # of market depth levels in Super Dom Properties).

    2nd Question:
    If I change the code e.g. to: for (int idx = 0; idx < 20; idx++), i.e. the intention is to limit the output to 20 levels, I get an error message and script will not be compiled.
    Can anybody explain why ?

    3rd Question:
    Is there a way to access data available in the SuperDom from a script that is used on the chart, i.e. not within Super DOM.
    Example: Can I process the best bid/ask value in super dom and create e.g. an indicator which uses this data for e.g. an indicator ?

    4th Question:
    ​Is there any help source and/or training available, where all the classes usable in ninja script are explained, i.e. statements like askRows.Count etc. ?

    5th Question:
    ​As far as I can see Depth Chart does not work properly, but it is also unknown which depth is used and if the depth shown here can be limited somehow.
    I miss a feature under e.g. Instruments where such a setting can be done.

    Last edited by TraderChris123; 04-13-2023, 07:04 AM.

    #2
    Hello TraderChris123,

    Thank you for your post and welcome to the NinjaTrader forum community!

    I would like to start by answering your 4th question and offering NinjaScript and C# resources to you. In the following post, my colleague links many great resources:The help guide has an entire NinjaScript section, including a Language Reference section that goes over methods and properties for various NinjaScript types:askRows.Count won't be specified in the help guide, however. This has to do with a C# list and is not NinjaScript specific. On the page where you may download the reference sample, there are some resources listed under "Important related documentation" including the following publicly available link for List<>:askRows is a list that is created in the script and that page will explain how lists work, including the Count property. For your 1st and 2nd questions, it sounds like this is related to the number of LadderRow objects contained in the list. The script compares the rows.Count with the e.Position parameter from OnMarketDepth(). If you want to limit the number of rows added to the list, you could adjust that logic to only add/remove a specified number of rows. I am not sure what error message you received when trying to change the loop to idx < 20. You could research what the error message means to get a better understanding of what caused it and how to resolve it.

    For your 3rd question, you could access ask and bid prices rather than the last price based on the data series used for input to the indicator. For example, see the marketDataType values available for AddDataSeries():


    I am not sure that I understand what you are explaining in your 5th question. What is your question here? Is this something that is not already addressed at this point? If so, please clarify and I would be glad to assist you further.

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

    Comment


      #3
      Thanks for your reply.

      Originally posted by NinjaTrader_Emily View Post
      If you want to limit the number of rows added to the list, you could adjust that logic to only add/remove a specified number of rows. I am not sure what error message you received when trying to change the loop to idx < 20. You could research what the error message means to get a better understanding of what caused it and how to resolve it.
      If I code:

      for (int idx = 0; idx < 20 /*askRows.Count*/; idx++)
      Print("Ask Price=" + askRows[idx].Price + " Volume=" + askRows[idx].Volume + " Position=" + idx);​

      Pls. see error message attached.


      5th Question:
      What is the depth on ask and bid side processed to generate this chart ?
      Attached Files

      Comment


        #4
        Hello TraderChris123,

        Thank you for your reply.

        I suspect that the error occurs when the loop tries to access an idx value in the list for an index that doesn't exist in the list. For example, if the list only has 7 values in it, once you try to access any index values greater than the number in the list it would throw that error. It is similar to the examples provided in this tip page:


        As I suggested in my previous post, "The script compares the rows.Count with the e.Position parameter from OnMarketDepth(). If you want to limit the number of rows added to the list, you could adjust that logic to only add/remove a specified number of rows​" Rather than changing the loop, you could change the number of values saved to the list.

        The bid and ask depth is retrieved from OnMarketDepth() which is an event-driven method called for every change in level II market depth data. This is described in the help guide:Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X