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

Multiple array declaration

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

    Multiple array declaration

    Hi,

    Is it possible to declare a multiple array, like this:

    private double[,,]MyArray= new double[100,100,100];

    But with different type of variables?, let's say: [double, int, int]. My idea is to store [Price, No of current Bar, an int].

    If not any idea that is simple?

    Thanks

    #2
    Hello Sangui,

    Thanks for opening the thread.

    It is possible to create an array of "object's" where you can use a variety of types, but you will have to type cast the instance of the object class if you are going to use it for variable assignment.

    Here is a publicly available resource that describes this further - https://stackoverflow.com/questions/...gle-array-in-c

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      I knew that but what I need is a kind of matrix, I mean:

      I want to store

      Data 1 > (Price1, int A1, int B1)
      Data 2 > (Price1, int A1, int B1)
      .
      .
      Data i > (Pricei, int Ai, int Bi)

      All within the same variable.

      Comment


        #4
        I know how to do it now

        private object[,,] Array = new object[100,100,100];

        Array[1,0,0] = 2000.45;
        Array[0,1,0] =1;
        Array[0,0,1] = 1;

        Array[2,0,0] = 3000.45;
        Array[0,2,0] =2;
        Array[0,0,2] = 5;

        double g =Convert.ToDouble(PivotUPArray[2,0,0]);

        Print("Value:"+g);

        Comment


          #5
          Hello Sangui,

          You could create a class that has member variables for the types that you want to store information for. Each of these variables will be associated with that class and you can use a List of that class to be able to index your classes.

          An example for creating a List using a custom class is described in the MSDN C# programming reference here - https://msdn.microsoft.com/en-us/lib....aspx#Anchor_8
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          11 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          7 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X