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

List<T> objects

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

    List<T> objects

    Hiya,

    Learning C# here, and came across List<T>, which looks like something I could use. Are we able to create List<T> objects in NT?

    Thanks.

    -Nick

    #2
    Yes, but you'll need to add a using statement.

    using System.Collections.Generic

    VT

    Comment


      #3
      Thanks for the quick reply!

      I was planning to use the List object to store a price points throughout the trading day. Now, to call the most recently added data, do I use:

      myList [count]

      or myList[0]

      ?

      I'm getting a bit confused because, DataSeries objects, which appears to be some kind of collection object, references the most recently added value with index[0].

      Comment


        #4
        It does run opposite from a DataSeries object.
        So try:
        myList[CurrentBar];

        That said, you might want to consider using a DataSeries object. it depends on what your needs are. But if you have a list and CalculateOnBarClose set to false. then you can create a much larger list than the number of bars. A DataSeries object will always be the same size.

        edit: I might have misunderstood you. If you want the index of the last value try:
        myList.Count - 1
        or to get the last value in the list try:
        myList.Last()
        or
        myList[myList.Count - 1]

        VT
        Last edited by VTtrader; 09-20-2011, 08:12 PM.

        Comment


          #5
          Thanks VTrader!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X