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

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=0kPlots_total;  i++ )    
            
    Add( new Plotshort_up_colorPlotStyle.Line"Plot" i.ToString() ) );

    I plot most recent close:

    PHP Code:
    protected override void OnBarUpdate()
    {
    int i;
        
        for( 
    i=0kPlots_totali++)
            
    Values[i].SetEMACloseperiods[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 Shansen, 08-30-2019, 10:18 PM
        24 responses
        938 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        3 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        2 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Working...
        X