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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        157 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        91 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        143 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        131 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X