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

Finding Min/Max value in a Series

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

    Finding Min/Max value in a Series

    Trying to figure out how to pass around arrays of double and find the min() or max() value in that Series.

    Tried to just create a double array, but that seems to have initialization challenges.

    Have resorted to doing this in a Series, but cannot find a method that allows me to retrieve the value from the Series.

    Help appreciated.

    Code is roughly:

    dval1 = new Series<double>(this);

    Looking to do something like:

    dval1.Max()

    #2
    Actually am working with NT8 and mistakenly started this in NT7 forum...

    Comment


      #3
      Hello RandyT,

      Thanks for your post.

      Arrays are a general C# concept, not to be confused with Series<T> objects, that you may find resources for externally to NinjaTrader.

      Series<T> objects are publicly documented in the help guide with example code to demonstrate how they are created. I may also recommend referencing how the Strategy Builder generates the NinjaScript syntax. You may create a Series<double> in the Additional Data page under Custom Series.

      Syntax from the help guide:
      Code:
      private Series<double> myDoubleSeries; // Define a Series<T> variable. In this instance we want it
                                            // as a double so we created a Series<double> variable.
       
      // Create a Series object and assign it to the variable
      protected override void OnStateChange() 
      {
          if (State == State.DataLoaded)
          {
              // "this" refers to the NinjaScript object itself. This syncs the Series object to historical data bars
              // MaximumBarsLookBack determines how many values the Series<double> will have access to
              myDoubleSeries = new Series<double>(this, MaximumBarsLookBack.Infinite);
          }
      }
      The MIN and MAX indicators can then be used to look at the minimun and maximum values going a specified number of bars back. The Strategy Builder can also be used to generate this syntax.

      MSDN documentation on Arrays - https://docs.microsoft.com/en-us/dot...-guide/arrays/

      Series<T> objects - https://ninjatrader.com/support/help...us/seriest.htm

      MIN - https://ninjatrader.com/support/help...inimum_min.htm

      MAX - https://ninjatrader.com/support/help...aximum_max.htm

      Valid Input for System Indicators - https://ninjatrader.com/support/help..._indicator.htm

      Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k

      Please let us know if you have any additional questions.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Lumbeezl, 01-11-2022, 06:50 PM
      31 responses
      817 views
      1 like
      Last Post NinjaTrader_Adrian  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      5 responses
      14 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by swestendorf, Today, 11:14 AM
      2 responses
      6 views
      0 likes
      Last Post NinjaTrader_Kimberly  
      Started by Mupulen, Today, 11:26 AM
      0 responses
      7 views
      0 likes
      Last Post Mupulen
      by Mupulen
       
      Started by Sparkyboy, Today, 10:57 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X