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

DataSeries and Classes

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

    DataSeries and Classes

    How do I Create a DataSeries for a Class I made

    IE here is my class


    public class myClass
    {
    public DateTime Time;
    public int BarIndex;
    public int PivotType;



    public PivotPoint(int nPivotType, DateTime tPivotTime, int nPivotBarIndex)
    {
    PivotType = nPivotType;
    Time = tPivotTime;
    BarIndex = nPivotBarIndex;

    }

    }


    here is my dataseries

    private DataSeries myDataSeries;



    here is y initialization

    myDataSeries = new DataSeries(this);

    now on bar update how do i add my objects in the the myClass

    #2
    Hello ballboy11,

    You would pass your data series to your custom class like the following,

    Code:
    public class myClassPivotPoint
    {
    		public DateTime Time;
    		public int BarIndex;
    		public int PivotType;
    
    	
    		public myClassPivotPoint(int nPivotType, DateTime tPivotTime, int nPivotBarIndex,[B] DataSeries s[/B])
    		{
    			PivotType = nPivotType;
    			Time = tPivotTime;
    			BarIndex = nPivotBarIndex;
    			
    			[B]mySeries=s;[/B]
    
    		}
    		
    }
    Declaring the data series in the indicator/strategy class,
    Code:
    	public DataSeries mySeries;
    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      i think I don't need a dataseries what I needed was an object array. is there a way to have dynamic array in

      private myClass[] myArray;
      protected override void OnStartUp()
      {
      // ClearOutputWindow();
      myArray = new myClass[10]; // instead of 10 size i want it dynamic


      //Print("Current array size: "+myArray.Length.ToString());
      }

      Can I have a dynamic array size or do I have to set the length of the array?

      Comment


        #4
        Hello ballboy11,

        You could use a list rather than an array. The advantages of a list is that it can dynamically change size. Please see the following,


        As well as a sample I uploaded today which uses lists.


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          You can create a list in NT7?

          Comment


            #6
            Hello ballboy11,

            Yes. You would need to add the following using statements,

            Code:
            using System.Collections;
            using System.Collections.Generic;
            Then could declare the list with,

            Code:
            public List<int> myList;
            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cls71, Today, 04:45 AM
            0 responses
            1 view
            0 likes
            Last Post cls71
            by cls71
             
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            213 views
            1 like
            Last Post PaulMohn  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            4 responses
            544 views
            0 likes
            Last Post PaulMohn  
            Started by GLFX005, Today, 03:23 AM
            0 responses
            3 views
            0 likes
            Last Post GLFX005
            by GLFX005
             
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            12 views
            0 likes
            Last Post XXtrader  
            Working...
            X