Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Top 3 Level 2 depths indicator

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

    Top 3 Level 2 depths indicator

    I am trying to script an indicator that would draw a dot for each of the top 3 bid depths and top 3 ask depths. I can't figure out how to get that data and sort it. I am assuming that I will need to drop all 10 depths of each side in to an array and sort them that way. First - how do I populate an array with that information assuming the arrays are:
    BIDDEPTH = new int[10]
    ASKDEPTH = new int[10]

    does that look right?

    Then - do I just use a massive IF THEN statement to sort them or can I use the:
    SORT(BIDDEPTH)
    command?

    Thank you so much in advance!

    #2
    Hello,
    Thank you for the question.

    For market depth there is a really good example we have posted on the forum that shows the process to get the depth, you would still need to get the results you are looking for but this will give you a framework to start with.



    There is also this example related to getting the level 2 data, this is a more advanced example that shows using custom timer events as well.


    For what you are trying to do the examples above use a List with a custom class defined as its object.
    I would recommend taking a look at some examples for basic List usage in C# to fully understand what is happening if you have not used a List before.

    With the List class you can get a count, reverse the list or get a value from a specified index.

    If you were only trying to get 3 results from the top of the list you could do something like the following:

    Code:
    for(int i - 0; i < 3; i++)
    	Print(askRows[i].Price);
    If you wanted it from the bottom you can use the Count or askRows.Count to get the amount of items in the list to loop through or do other logic.

    Please let me know if I may be of additional assistance .
    JesseNinjaTrader Customer Service

    Comment


      #3
      How would I get the top 3, as in the highest value, rows? Not just rows 0 -2. But if out of all 10 rows, rows 5, 7 and 8 were of the highest value. I want the array to contain those - or at least have the array sorted from highest value to lowest.

      Comment


        #4
        Hello bchirhart,

        Thank you for your response.

        So are you looking for the lines at the largest values of depth? Or the highest position reached on the ladder (max row)? And is this just on the current data or over a period?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        4 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Brevo, Today, 01:45 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        74 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by suroot, 04-10-2017, 02:18 AM
        5 responses
        3,021 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Stanfillirenfro, Today, 07:23 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X