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 Array

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

    DataSeries Array

    When I use this declaration...

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
    double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][,] MovingAverage=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] DataSeries[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]];[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT]
    I cannot access a .Set method ie.

    Code:
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]MovingAverage[x,y].Set(SMA(BarsArray[x],MATF[y]));[/SIZE][/FONT][/SIZE][/FONT]
    Is it possible to create array's of a DataSeries?

    #2
    Unfortunately this is beyond what is supported.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Code for making Array of DataSeries

      In Variables region:
      private DataSeries [] Value1;
      private DataSeries [] Array2; /// a different array of DataSeries


      In Initialize:
      Value1 = new DataSeries [4]; // or whatever length you need
      Value1[0] = new DataSeries (this);
      Value1[1] = new DataSeries (this);
      Value1[2] = new DataSeries (this);
      Value1[3] = new DataSeries (this);
      Array2 = new DataSeries [18];
      Array2[0] = new DataSeries (this);
      .......
      Array2[17] = new DataSeries (this);

      In OnBarUpdate:
      // or what ever init you need to zero out
      if (CurrentBar < (2 * alpha)) {
      for (int i = valstart; i <= valmax; ++i) {
      Value1[i].Set(0);
      Array2[i].Set(0); // yet another array
      }
      return;
      }

      In code Body
      for (int i = valstart; i <= valmax; ++i) {
      Value1[i].Set(SMA(Input, 40)[0]); // or whatever
      Array2[i].Set(EMA(Input, 40)[0]); // or whatever
      ......
      Biggie = MAX(Value1[i], alpha)[0] -
      MIN(Array2[i], beta)[0];; /// or whatever
      }

      Hope this helps
      Roland

      Comment


        #4
        System.

        It is possible, but I think you have to do something more along the lines of..

        (Just to reiterate what roland said)

        Variables
        Code:
        private DataSeries[] sMAs;
        Initialize
        Code:
        sMAs = new DataSeries[28];
        for (i = 1; i <= 27; i++)
              sMAs[i] = new DataSeries(this);
        OnBarUpdate
        Code:
            sMAs[1].Set(EMA(Close, 5)[0]);
            sMAs[2].Set(EMA(Close, 8)[0]);
        This is of course a 1-D Array sample. For 2D just expand the index identifier.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Thanks for the great information guys ... I can follow what Roland said, but what if I wanted to define a DataSeries that looked like BarsArray and I wanted to populate its Open,High,Low,Close,Volume fields myself then pass this to a function such as Stochastic (which uses more than just the close parameter). Is this possible?
          Basically what I want to do is be able to build my own DataSeries similar to the ones generated by the Add() then be able to manipulate the data put into them.

          Eg
          Array2[i].Set(Stochastics(myArray[1], 3,8,10).D[0]);

          where myArray is a custom made array the same as BarsArray.

          Kind Regards
          Steve

          Comment


            #6
            Steve,

            You could just make the array yourself through C# and just add values on every for every single bar.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              This sounds like what I want to do, however I don't know how to make it in C#. Especially since I dont know the format the BarsArray uses. Do you or anyone else have some sample code, or is there anyone that could point me in the right direction to be able to do this?

              Thank
              Steve

              Comment


                #8
                OzSteve,

                Actually I recommend you just create DataSeries objects and store values directly. Skip the array. Just make as many DataSeries objects as you need since you will need to copy them into a DataSeries anyways from an array if you want to use them from within an indicator.

                You can see how to use BarsArray from the Help Guide article here: http://www.ninjatrader-support.com/H...BarSeries.html
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Josh,
                  I looked at the referenced link and it only tells me how to handle the BarsArray, what I really need is to learn how to WRITE data to a BarsArray object so that a standard indicator functon can read it.

                  You mention in your post that I shouldn't use an array but rather just use a number of DataSeries (I would take it you are recommending one for OPEN, one for CLOSE, one for HIGH and one for LOW etc)? If I take this approach then I believe any indictor functions I call, I will need to rewrite the indicator function as it will need to be modified to handle passing of multiple DataSeries rather than a single BarsArray. Is this correct? If so it seems like a hard way to go. Wouldn't it be easier to just build a BarsArray object and pass this to the function? Like NT does generically now???

                  My question is ... HOW can I build a custom BarsArray that I can WRITE data values to then pass to other functions, or manipulate using parameters such as Close[2][3]. This is what I've been trying to work out for a couple of weeks now and I don't seem to be getting anywhere. There doesn't seem to be any documentation on doing this. Your help would be really appreciated.

                  Kind Regards
                  Steve

                  Comment


                    #10
                    Steve, please take a look at your other thread regarding the same issue...to write to a data series, please use the DataSeries.Set() method - http://www.ninjatrader-support.com/H...iesObject.html
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Create an array of dataseries objects

                      Maybe this is what you are looking for:

                      Last edited by Ricam; 09-23-2015, 03:51 PM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Skifree, Today, 03:41 AM
                      5 responses
                      13 views
                      0 likes
                      Last Post Skifree
                      by Skifree
                       
                      Started by Mongo, Today, 11:05 AM
                      3 responses
                      14 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by traderqz, Today, 12:06 AM
                      7 responses
                      13 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by traderqz, Yesterday, 09:06 AM
                      5 responses
                      34 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by guillembm, Today, 11:25 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Working...
                      X