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

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.


      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.
      Gain technical skills through documentation and training, earn certifications and connect with the community


      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 cre8able, Today, 01:16 PM
      2 responses
      9 views
      0 likes
      Last Post cre8able  
      Started by chbruno, 04-24-2024, 04:10 PM
      3 responses
      48 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by samish18, Today, 01:01 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by WHICKED, Today, 12:56 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by WHICKED, Today, 12:45 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X