Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing a Historical series/Lijn Reg

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

    Passing a Historical series/Lijn Reg

    This may be a silly question but I am not that versed in Ninja.

    I am wanting to use the linreg function to return the vale of a specific bar within a linreg series based on a specific lookback, starting on a previous bar.

    Looking at the linreg function it looks like I could simple call the linreg function with a source of something like Typical[7], which means pass the series to calculate the linreg function from starting 7 bars ago and then the series would be from bar 7 back to the length of the lookback.

    Then what is returned from the linreg function would be the linreg value at the bar 7 bars ago, based on the series that started 7 bars ago, not on the most recent bar created.

    You can easily visualize this by taking a linreg drawing tool and drawing between several historical bars a linreg line. I just want to be able to get those values.

    The problem is I can't think of how to do this easily.

    Could someone suggest an easily solution?

    #2
    well I just looked at the code for the linreg function, and it looks like I could simply modify it to allow for the passing of a START_NUM_OF_BARS_BACK variable. Then simple call this modified function with now 2 values, a lookback and a start back bar. This seems like it would work.

    Any easier ways?

    Comment


      #3
      philli, I would think drawing a Regression Channel by code and then working with the midline's endpoint might be easier - http://www.ninjatrader.com/support/h...ionchannel.htm

      Comment


        #4
        Thanks for the response. I didn't realize the drawing tools could return values as a function. So looking at this, it appears I could plot the channel and then read the regression.EndY, to obtain the price value at the end point. What if I wanted to get a value within the end and start point, is there a way to reference that, would i use a [x] to look back x bars?

        Thanks!

        Comment


          #5
          You're welcome, for those values you would need to move the channel anchors and read out the new endpoint value so you can build a series - which is the same as the LinReg function referenced x bars back - like double value = LinReg(20)[5]; // the value of the LinReg over the past 20 bars 5 bars ago.

          Comment


            #6
            ah..didn't think of that approach...lol

            Comment


              #7
              B,

              Gave this a shot and it does not return the value of the ENDY or STARTY when referenced.

              I used this line

              // Draw Regression Line
              IRegressionChannel rgt = DrawRegressionChannel("dReg",e,a,Color.AntiqueWhit e);
              dRC=rgt.EndY; // Get the linreg value at last bar of channel.

              a and e are the start and end bar values.

              This plots the linreg channel correctly but I cannot read the .ENDY value it comes back as 0.

              Comment


                #8
                philli4093, I will look into why you're seeing this as 0 - the value itself is the same as the lastValue of the LinReg indicator, you can see it through time as well with it.

                Comment


                  #9
                  Thanks for reporting this bug in philly, it should be fixed within the next NT7 update.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  601 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  347 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  103 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  559 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  558 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X