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

Limit number of rows reference SampleLevel2Book

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

    Limit number of rows reference SampleLevel2Book

    Hi,

    how whould I change Reference Sample SampleLevel2OrderBook to only store and update a fixed number of rows of Level 2 Data e.g. 5 Levels?

    Tried several attempts, but cant get it working properly.

    Regards and thanks.

    #2
    Hello keepsimple, and thank you for your question. I was unable to find the reference sample that you are referring to. Could you attach your copy to a reply, or a link to this sample on the web? I look forward to assisting further.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3

      Comment


        #4
        Thank you for providing a link to the SampleLevel2Book reference sample keepsimple. While modifying this indicator to meet your specifications goes beyond the scope of the support we may provide, I will be happy to modify parts of this sample to demonstrate some of the NinjaScript functionality you will need, reducing this from a script that requires both C# and NinjaScript development and understanding to one that requires only C#. If you would like assistance above and beyond this please let us know so we may contact a certified NinjaScript consultant.

        One thing we will need is a property which lets us limit the number of row. The code for that goes on line 107, and looks like this :

        Code:
        [FONT=Courier New]        #region Properties
        [B]        [Range(1, int.MaxValue), NinjaScriptProperty]
                [Display(ResourceType = typeof(Custom.Resource), Name = "NumRows", GroupName = "NinjaScriptParameters", Order = 0)]
                public int NumRows
                { get; set; }[/B]
                #endregion[/FONT]
        Once we have this parameter, we can then look at how the rows are constructed. It turns out that this is actually 2 lists, which we discover on line 91 :

        Code:
        [FONT=Courier New]
                        List<LadderRow> rows = (e.MarketDataType == MarketDataType.Ask ? askRows: bidRows);[/FONT]
        You can use the publicly available MSDN documentation here to determine how to only select numRows members from either askRows or bidRows :



        Note : If you study the rest of the code between lines 91 and 102, you will see that we add one more row, so you actually want to grab NumRows - 1 elements to make room for the added row.
        Note : You may want to enforce a minimum value for NumRows that is greater than 1 to prevent negative indices.

        Finally, after line 102, you can assign either askRows or bidRows to this slice containing only NumRows elements using the same condition you used on line 91.

        Please let us know if we can assist further.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        32 views
        0 likes
        Last Post Pattontje  
        Started by abdo22, Yesterday, 03:15 PM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by f.saeidi, Yesterday, 02:09 PM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Jltarrau, Today, 05:57 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by kujista, Today, 06:23 AM
        0 responses
        2 views
        0 likes
        Last Post kujista
        by kujista
         
        Working...
        X