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

Examples of good ways of working with Series data as array?

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

    Examples of good ways of working with Series data as array?

    I was wondering if someone could offer some good examples of how to work with values in a Series more as if it were an Array.

    I've taken to doing things like the following to snip a length of values from a Series type to then do things like Sum(), Sort(), ranking, etc.

    Code:
    static public double[] ArrayQueueToArray(Series<double> aq, int length)
            {
                double[] toArray = new double[length];
                for (int i = 0; i < length; i++) {
                    toArray[i] = aq[i];
    			}
                return toArray;
            }
    I'm wondering there are any methods available to me that makes it a bit cleaner than the above that I am unaware of.

    If not, this could be considered a request for enhancement to allow these types of manipulations.

    #2
    To expand on this a bit more...

    I need to maintain an Array with the last 10 values.

    Can I create the Series with MaximumBarsLookBack value of 10?

    Code:
    myQueue = new Series<double>(this, 10);
    I'm also doing things like the following, which seems awkward.

    Code:
    stdDevQ = new Series<double>(this, MaximumBarsLookBack.TwoHundredFiftySix);
    stdDevVal = StdDev(stdDevQ, Length);
    
    stdDevVal[0] = (Close[0] / Close[1]);
    
    // copy last 10 values from Series and Sum().
    val1 = Math.Sum(FunctionToCopySeriesVals(stdDevVal, 10));
    Is there a cleaner way which I have not figured out?

    I appreciate any guidance on this.

    Comment


      #3
      Hello RandyT,

      Thanks for your post.

      Series<T> objects can be synchronized entirely to the data series with MaximumBarsLookBack.Infinite or with only the last 256 values with MaximumBarsLookBack.TwoHundredFiftySix. There currently are not any other MaximumBarsLookBack options.

      My recommendation would be to take the same approach you currently are; to make a function that will convert the series to an array of your desired length and then use the array as you normally would.

      I've submitted two feature requests on your behalf for consideration in a new version of NinjaTrader:

      Ability to customize MaximumBarsLookBack values - SFT-3432
      Additional methods for Series<T> to be used like Arrays - SFT-3433

      Feature request interest is collected before it is decided if the feature should be implemented, so we can't offer an ETA. Once implemented, the ticket ID can be found publicly on the Release Notes page of the help guide.

      Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

      If there is anything else we can do to help, please let us know.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Started by alifarahani, Today, 09:40 AM
      6 responses
      41 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      21 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X