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

Minimum value of a group of variables

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

    Minimum value of a group of variables

    Hi

    I am trying to get the minimum value of a group of variables, say the range of the last 5 bars (range1, range2, range3 etc). I tried calling the Math.Min Function but it only allows 2 variable inputs. Is there any easy way to get the minimum value of variables (I know how to do it for Price data series, with MIN and MAX).

    Also if I wanted to write my own method to execute such a function how would I do so? I have tried to use the custom event handler with no success as well as inputting my own code for a method but I keep getting errors.

    Thanks so much

    #2
    Hello EuroStoxx Trader,

    MIN() is what you're looking for here. It can accept any DataSeries as input. It will most likely be easier to turn the value you're looking to MIN into a data series than create your own custom method.

    See here for a tutorial on DataSeries.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply, but I am still having some trouble using the MAX function on a 2nd data series. I decided to just to make my own indicator, rather than using another data series in the strategy but alas i realized its the same problem.

      So if I were to make an indicator that uses a data series of bar ranges as the new DataSeries (high[0] - Low) how can you retrieve the values for the MAX range of the last 4 instances.

      Basically I am not sure how to add a 2nd data series with the MAX function. This is what I have been using but it just returns the high of the past 4 bars, not the high of my new dataseries

      double max_range_bar4 = MAX(High, 4)[0];

      Comment


        #4
        eurostoxx trader, instead of passing the High values as input in, try for example running the MAX / MIN on the Range() indicator which would return the high - low range of the bars as dataseries if you don't access it with an index - i.e. MAX(Range(), 10)[0]
        BertrandNinjaTrader Customer Service

        Comment


          #5
          thanks so much... that worked just fine!.... i didnt realize you could replace the "high" in the max function.. wow

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yertle, 04-18-2024, 08:38 AM
          9 responses
          40 views
          0 likes
          Last Post yertle
          by yertle
           
          Started by techgetgame, Yesterday, 11:42 PM
          0 responses
          9 views
          0 likes
          Last Post techgetgame  
          Started by sephichapdson, Yesterday, 11:36 PM
          0 responses
          2 views
          0 likes
          Last Post sephichapdson  
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,615 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Yesterday, 05:56 PM
          0 responses
          10 views
          0 likes
          Last Post jaybedreamin  
          Working...
          X