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

LRO question

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

    LRO question

    Hello,
    i suspect there is something wrong with this code:
    Code:
    int x = LRO(delegate {return Close[0] == High[0];}, 2, maxLineLenght);
    I presume that the search is done on the line of the last closed bar.
    And it must be done at the last HIGH bar which is not the last closed bar.
    any help would be appreciated

    #2
    Hello mate41,
    The code will return the 2nd last bar number (from maxLineLength) where the Close is equal to the bar High value.

    To assist you further may I know what value you are getting, and what do you expect.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Joydeep View Post
      Hello mate41,
      The code will return the 2nd last bar number (from maxLineLength) where the Close is equal to the bar High value.

      To assist you further may I know what value you are getting, and what do you expect.
      I want the number of the 2 lasts Highs of the same high price.
      And the same for the 2 last Lows of the same low price.
      Purpose is to trace the support and resistance line.
      At any Close[0] on Barupdate.

      Comment


        #4
        Hello mate41,
        You have to make 2 calls to find the 2 bar numbers.

        Code:
        int x2 = LRO(delegate {return Close[0] == High[0];}, 2, maxLineLenght);
        int x1 = LRO(delegate {return Close[0] == High[0];}, 1, maxLineLenght);
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Hi Joydeep,
          That's not what i want, maybe this would help but there is still a problem:

          Code:
          if (CurrentBar < maxLineLenght + 3) return;
          int z = HighestBar(Close, maxLineLenght);
          int x = LRO(delegate {return Close[0] == High[z];}, 2, maxLineLenght);
          And the error:
          Code:
          Error on calling 'OnBarUpdate' method for indicator 'ResSupDynamicsOld' on bar 123: 'LRO' on bar 3 threw exception: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
          First line = return if the currentbar isn't greather than.....
          Second = find the highest bar
          Third = at this highest bar look for 2 highs on the previous high price.
          After that i trace a line from the founded highs to the Close[0] bar.

          Comment


            #6
            Hello mate41,
            If you try the below code then are you able to run it.

            Code:
            if (CurrentBar < maxLineLenght + 3) return;
            
            int z = HighestBar(Close, maxLineLenght);
            double high = High[z];
            	
            int x = LRO(delegate { return Close[0] == high;}, 2, maxLineLenght);
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by hazylizard, Today, 08:38 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by geddyisodin, Today, 05:20 AM
            2 responses
            17 views
            0 likes
            Last Post geddyisodin  
            Started by Max238, Today, 01:28 AM
            5 responses
            45 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by giulyko00, Yesterday, 12:03 PM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by habeebft, Today, 07:27 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Working...
            X