Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to sync arraylist (or similar collection) to current bars?

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

    How to sync arraylist (or similar collection) to current bars?

    I am working on a strategy with a very large amount of instruments (200-2000). I have found that if I call indicators by the standard methods in NinjaTrader, the memory usage quickly blows up.

    For reference, please see my related post:



    To correct this, I have moved all of my indicator calculations inside of my strategy, and call them using custom functions rather than the NinjaTrader ones.

    My question is:
    - For the ADX calculation, there are 7 separate DataSeries that are typically stored
    > dmPlus, dmMinus, sumDmPlus, sumDmMinus, sumTr, tr, ADX

    - I would like to make a single DataSeries that contains all of these items, by creating my own class

    Code:
    public class iADX
    {
    	public double dmPlus;
    	public double dmMinus;
    	public double sumDmPlus;
    	public double sumDmMinus;
    	public double sumTr;
    	public double tr;
    	public double ADX;
    }
    
    ...
    ...
    
    private DataSeries[] cADXs = new DataSeries[numberInstruments]; 
    
    ...
    
    for (int i = 0; i <= numberInstruments; i++)
    {
       cADXs[i] = new DataSeries(this);
    }
    Is there any way to code this so that I can generate a collection of iADX members, and also have it synced to the bars (like a DataSeries would be?)

    For example:
    Code:
    for (int i = 0; i <= numberInstruments; i++)
    {
       cADXs[i] = new iADX;
    }
    
    ...
    cADX[i].dmPlus = someNumber
    cADX[i].dmMinus = someOtherNumber
    Last edited by kbeary33; 07-12-2013, 07:48 PM.

    #2
    Note that the closest that I think that I have come would be to use something like this:

    Code:
    [Description("Relative Ranking System")]
    public class MyRankingSystem : Strategy
    {
    
    public class iADX
    {
       public DataSeries dmPlus = new DataSeries(this);
       public DataSeries dmMinus = new DataSeries(this);
       public DataSeries sumDmPlus = new DataSeries(this);
       public DataSeries sumDmMinus = new DataSeries(this);
       public DataSeries sumTr = new DataSeries(this);
       public DataSeries tr = new DataSeries(this);
       public DataSeries ADX = new DataSeries(this);
    }
    Unfortunately, it seems like I can't use the keyword "this" from inside the iADX class. Is there any way of referencing the "this" keyword, as it would be in the context of the overall MyRankingSystem code? (ie, anywhere outside of the iADX class block)

    Comment


      #3
      Hello kbeary33,

      Custom classes inside of NinjaTrader are not something that is not supported.

      "this" is also just a reference of the current class, which you may not want to initialize inside of your embedded class.
      The `this` keyword clarifies access to the current instance of a type, or declares an indexer on the type.


      With that said, if you would only like one object with multiple DataSeries you may want to look into an Array. This way you may have an array of DataSeries.
      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


      Note that Arrays are also not supported but would be easier to work with instead of a class.
      JCNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      174 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      328 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      252 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      355 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      181 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X