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 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
      BertrandNinjaTrader Customer Service

      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.
          BertrandNinjaTrader Customer Service

          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.
                BertrandNinjaTrader Customer Service

                Comment


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

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Jimmyk, 01-26-2018, 05:19 AM
                  6 responses
                  835 views
                  0 likes
                  Last Post emuns
                  by emuns
                   
                  Started by jxs_xrj, 01-12-2020, 09:49 AM
                  6 responses
                  3,291 views
                  1 like
                  Last Post jgualdronc  
                  Started by Touch-Ups, Today, 10:36 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post Touch-Ups  
                  Started by geddyisodin, 04-25-2024, 05:20 AM
                  11 responses
                  62 views
                  0 likes
                  Last Post halgo_boulder  
                  Started by Option Whisperer, Today, 09:55 AM
                  0 responses
                  9 views
                  0 likes
                  Last Post Option Whisperer  
                  Working...
                  X