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

Better practice to store a collection of data

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

    #31
    Hello bltdavid​.
    I have been working with the ListSeries and they really improves the way to look at the data.

    I would like to store the price and the bar number (CurrentBar) of the ZigZag edges or angles. In terms of machine utilization and performance what would you recommend A) Using two Lists B) Using one ISeries<double>( I will know the price and the bar since only the bars where the edge appears are going to be with a valid


    The problems I'm facing are related with this two issues:
    A) Some due to combinations of two different data, some no longer valid pivots get stocked in the trail.
    Question a): Is there any chance to make some changes the code (as you kindly did with the RemoveLast) in order to have something similar to RemoveAt (used in lists)?
    B) The standard and supported way to communicate between two indicators is though adding the slave indicator as private in the master indicator and then in the master indicator the plots and the variables shall be set as public ( not public static). I tried to combine both to public but the master indicator get error and doesn't save. I tried to set Values[0] to public static but l got no luck.
    Question b): is there a chance to be able to set the ListSeries as public only? as i was trying, the variables (ListSeries) appeared in the intellisense, but then appear an error at the time to save the workspace.
    Thank you very much!!!

    Comment


      #32
      Originally posted by efeuvejota01 View Post
      I have been working with the ListSeries and they really improves the way to look at the data.
      Glad you enjoy using it!

      Originally posted by efeuvejota01 View Post
      ​Question a): Is there any chance to make some changes the code (as you kindly did with the RemoveLast) in order to have something similar to RemoveAt (used in lists)?
      Done.

      I've added RemoveAt() per your request.
      Download the attached file and replace your current copy.

      Originally posted by efeuvejota01 View Post
      ​Question b): is there a chance to be able to set the ListSeries as public only? as i was trying, the variables (ListSeries) appeared in the intellisense, but then appear an error at the time to save the workspace.
      Of course.

      I think the root cause is that you are unaware that all public
      properties and all public variables in the Indicator class are
      Xml serialized.

      [EDIT: Actually, it's any class, not just Indicator. The concept
      of Xml Serialization is a C#/.NET thing, not a NinjaScript thing.]

      It seems that your attempt to mark a ListSeries<T> variable
      as public in your Indicator is causing you problems when
      saving the workspace. I'm assuming the issue is an Xml
      serialization error.

      How to fix it?
      Simple. Same as with public properties, you must add the
      [XmlIgnore()] attribute to the public variables that need
      to skip Xml serialization.

      For example, update this line,

      public ListSeries<int> zzBars = null;

      to this,

      [XmlIgnore()] public ListSeries<int> zzBars = null;

      I like to place the [XmlIgnore()] directly in front of the
      public definition, but you could also place the attribute
      on a line by itself.

      -=o=-

      What if you don't want to use XmlIgnore? I mean, what if
      you really do need to make your ListSeres<T> persistent?
      Well then, you're kinda on your own.

      I've never cared about actually serializing the data contained
      in a ListSeries<T>. I have always used the XmlIgnore
      attribute to just ignore the variable entirely.

      Remember, Xml serialization is not about sharing data
      between two different running indicators.​ Xml serialization
      is about storing instance data on disk, in an Xml file, such
      that the data can be restored to a new instance later. For
      ex, say you exit/restart NT, it is the saved data in the Xml
      file that is used to populate the new instance after restart.

      [​If you really need to make your ListSeries<T> serializable,
      that is an entirely different problem, and it depends on just
      how complex is your type T. If I had to do it, I would use
      the 'convert to a string' trick, using a special-purpose non-
      browsable property, like is currently done when serializing
      brushes.]
      Attached Files
      Last edited by bltdavid; 06-28-2023, 05:36 AM.

      Comment


        #33
        Thank you very much!!
        Let me digest it....
        FVJ

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by llanqui, Today, 10:32 AM
        0 responses
        2 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,992 views
        3 likes
        Last Post johntraderuser2  
        Started by TAJTrades, Today, 09:46 AM
        0 responses
        8 views
        0 likes
        Last Post TAJTrades  
        Started by rhyminkevin, Yesterday, 04:58 PM
        5 responses
        62 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by realblubb, Today, 09:28 AM
        0 responses
        8 views
        0 likes
        Last Post realblubb  
        Working...
        X