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 arvidvanstaey, Today, 02:19 PM
        2 responses
        7 views
        0 likes
        Last Post arvidvanstaey  
        Started by jordanq2, Today, 03:10 PM
        0 responses
        5 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        46 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by mmckinnm, Today, 01:34 PM
        3 responses
        6 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X