Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing High or Low into FindLastIndex()

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

    Passing High or Low into FindLastIndex()

    I concede that this is not a NinjaTrader specific question but I am not sure how to cast this method call properly:

    int index1 = Array.FindLastIndex(Highs[0], item => item == High[0]);

    What I'm basically trying to do is to get the last index of the current high. The method call fails as obviously FindLastIndex does not know anything about the High array. I tried to parameterize with <double> but ran into all kinds of trouble. If anyone (more verse in C# collections than I) could point me the right way I would very much appreciate it.

    #2
    Originally posted by molecool View Post
    I concede that this is not a NinjaTrader specific question but I am not sure how to cast this method call properly:

    int index1 = Array.FindLastIndex(Highs[0], item => item == High[0]);

    What I'm basically trying to do is to get the last index of the current high. The method call fails as obviously FindLastIndex does not know anything about the High array. I tried to parameterize with <double> but ran into all kinds of trouble. If anyone (more verse in C# collections than I) could point me the right way I would very much appreciate it.
    If we knew what your end was, I might be better able to answer the question, but purely from a syntax standpoint, the array is Highs and the members are Highs[x], so that line should probably read:

    Code:
     
    int index1 = Array.FindLastIndex(Highs, item => item == Highs[0]);
    But that would seem to always return a value that is identically zero, as that should always be the first item in the array?

    Comment


      #3
      Right... sorry.

      Originally posted by koganam View Post
      If we knew what your end was, I might be better able to answer the question, but purely from a syntax standpoint, the array is Highs and the members are Highs[x], so that line should probably read:

      Code:
       
      int index1 = Array.FindLastIndex(Highs, item => item == Highs[0]);
      But that would seem to always return a value that is identically zero, as that should always be the first item in the array?
      Sorry, I should have used FindIndex() instead. The goal of the exercise is to figure out if there was a high of the same value previous to current one. In a way I am trying to write a isHighest() routine which returns true only if it's the single highest value in the array.

      Comment


        #4
        Originally posted by molecool View Post
        Sorry, I should have used FindIndex() instead. The goal of the exercise is to figure out if there was a high of the same value previous to current one. In a way I am trying to write a isHighest() routine which returns true only if it's the single highest value in the array.
        That sounds like you are looking for the highest value of a single DataSeries. I cannot seem to see what that has to do with an Array of DataSeries? I seem to be lost.
        Last edited by koganam; 11-25-2012, 04:58 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        562 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        325 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
        547 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