Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get largest val from array of plots

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

    Get largest val from array of plots

    I have an array of plots:

    PHP Code:
    protected override void Initialize()
    {
    int i;
        for( i=0; i < kPlots_total;  i++ )    
            Add( new Plot( short_up_color, PlotStyle.Line, "Plot" + i.ToString() ) );
    } 
    
    I plot most recent close:

    PHP Code:
    protected override void OnBarUpdate()
    {
    int i;
        
        for( i=0; i < kPlots_total; i++)
            Values[i].Set( EMA( Close, periods[i] )[0] );
    } 
    
    All this works fine. I would like to know the min and max values that I just plotted. I was hoping MAX() would work, but according to the documentation it only works with iDataSeries not arrays of iDataSeries. Am I missing something? It is not a problem to loop through and find the min and max in code. Just wanted to use existing functionality where possible.

    #2
    Hi bernie_c,

    When calling MAX() pass the dataseries, not the entire array of dataseries.

    i.e. MAX(Values[1], 20)[0]

    Values is the array of data series. Values[1] is the second dataseries object.

    http://www.ninjatrader.com/support/h...aximum_max.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I don't want the largest value in a range of a single dataseries. I want to look at all the dataseries in the array and find the one with the largest value in the 0 barsAgo position. This largest value is what I am after.

      Comment


        #4
        Hello bernie_c,

        You will need to make a custom loop to do this. There is not a method in C# that does this that I know of.

        For example:

        double largest = 0;
        for (int i = 0; i<BarsArray.Count-1; i++)
        {
        if (Closes[i][0] > largest)
        largest = Closes[i][0];
        }
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X