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 timmbbo, Today, 08:59 AM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by KennyK, 05-29-2017, 02:02 AM
            2 responses
            1,281 views
            0 likes
            Last Post marcus2300  
            Started by fernandobr, Today, 09:11 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by itrader46, Today, 09:04 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by bmartz, 03-12-2024, 06:12 AM
            5 responses
            33 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Working...
            X