• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fewer lines

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

    Fewer lines

    How can I do this in fewer lines?

    double[,] a = new double[,] {
    {Open[0],Low[0],High[0],Close[0]},
    {Open[1],Low[1],High[1],Close[1]},
    {Open[2],Low[2],High[2],Close[2]},
    {Open[3],Low[3],High[3],Close[3]},
    {Open[4],Low[4],High[4],Close[4]},
    {Open[5],Low[5],High[5],Close[5]},
    {Open[6],Low[6],High[6],Close[6]},
    {Open[7],Low[7],High[7],Close[7]},
    {Open[8],Low[8],High[8],Close[8]},
    {Open[9],Low[9],High[9],Close[9]},
    {Open[10],Low[10],High[10],Close[10]},
    {Open[11],Low[11],High[11],Close[11]},
    {Open[12],Low[12],High[12],Close[12]},
    {Open[13],Low[13],High[13],Close[13]},
    {Open[14],Low[14],High[14],Close[14]},
    };
    Last edited by eleven; 09-08-2015, 11:33 AM.

    #2
    How can I create a multidimensional array of OHLC of a certain length better than what I posted above? Any help would be appreciated.

    Thanks.
    Last edited by eleven; 09-07-2015, 07:01 PM.

    Comment


      #3
      Hello,

      This would require a for loop to make this more simplified or less lines.

      Here is a simple example of using a multi-dimensional array in a loop:

      Code:
       protected override void OnBarUpdate()
      {
                  if (CurrentBar < 14) return;
                 double[,] a = new double[15,4];
      
      			//set values
                  for (int i = 1; i < 15; i++)
                  {
      				a[i,0] = Open[i];
      				a[i,1] = Low[i];
      				a[i,2] = High[i];
      				a[i,3] = Close[i];
                  }
      			
      			//usage
      			for (int i = 1; i < a.GetLength(0); i++)
                  {
                      Print("Open: " + a[i, 0] + " Low: " + a[i, 1]+ " High: " + a[i, 2]+ " Close: " + a[i, 3]);
                  }
      }

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Thanks for your assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by chafan11, Today, 09:28 PM
        0 responses
        5 views
        0 likes
        Last Post chafan11  
        Started by GreenspanAlec, Today, 05:32 PM
        0 responses
        6 views
        0 likes
        Last Post GreenspanAlec  
        Started by mrwarkhan, Today, 03:45 PM
        0 responses
        13 views
        0 likes
        Last Post mrwarkhan  
        Started by momchi, Yesterday, 10:09 PM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by Jesus Medina, Today, 02:43 PM
        0 responses
        6 views
        0 likes
        Last Post Jesus Medina  
        Working...
        X