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 aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        238 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        4 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        125 views
        0 likes
        Last Post Leeroy_Jenkins  
        Working...
        X