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

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 RubenCazorla, 08-30-2022, 06:36 AM
        3 responses
        77 views
        0 likes
        Last Post PaulMohn  
        Started by f.saeidi, Yesterday, 12:14 PM
        9 responses
        23 views
        0 likes
        Last Post f.saeidi  
        Started by Tim-c, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by FrancisMorro, Today, 03:24 AM
        0 responses
        4 views
        0 likes
        Last Post FrancisMorro  
        Started by Segwin, 05-07-2018, 02:15 PM
        10 responses
        1,772 views
        0 likes
        Last Post Leafcutter  
        Working...
        X