Announcement

Collapse
No announcement yet.

Plotting LR starting x number of bars back.

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

  • Plotting LR starting x number of bars back.

    Two questions:

    1. What exactly does the "barIndex" represent in: upperLinearReg( length, stdDev [, source | sym() | inv()] [, barIndex] )?
    2. How can I define a starting point for the lookback "length" value in the code so it plots the LR for say a length of 30 starting 25 bars back?

    I would like to modify the "customLinearRegression.efs" found in the ...\Formulas\EFS 2 Custom subdirectory so that it displays the linear regression lines starting from a set # of bars back (i.e., -20) and draws the LR lines for a specified length, say 25.

    The following code from the efs doesn't seem to have a starting point.

    xUpLR = upperLinearReg(Length, StdDev,eval(Source)());

    The "eSignal EFS Developer's Reference" allows for "barIndex" to be added as the last parameter of the above code but it caused an error message.
    It seems that when a "barIndex" is added to the end of the above code (see next two lines of code as my example) it returned a null value.

    xUpLR = upperLinearReg(Length, StdDev,eval(Source)(),25);
    or
    xUpLR = upperLinearReg(Length, StdDev,eval(Source)(),-25);

    Thank you for any help
    Attached Files
    Last edited by waynecd; 04-26-2008, 10:25 PM.

  • #2
    waynecd
    1. The barIndex parameter allows you to directly retrieve the value of a study at the specified bar index ie without first creating the series and then retrieving its value using the getValue() method. You may want to review this thread for a set of examples illustrating its use.
    2. The starting point for the calculation of the built-in linear regression functions is defined by the length parameter. The function then calculates and plots the linear regression from that point to the most recent bar (unless you set the length to 0 in which case it calculates the linear regression based on all the data in the chart)
    If you are trying to extend the linear regression lines beyond the last bar then you need to keep in mind that an efs does not plot where there are no price bars so you will have to draw the segments of the linear regression that extend beyond the last bar.
    To do this you will need to calculate the slope of the linear regression and then use that to determine the end points of the line(s) that are drawn into the future (ie beyond the last bar).
    Alex


    Originally posted by waynecd
    Two questions:

    1. What exactly does the "barIndex" represent in: upperLinearReg( length, stdDev [, source | sym() | inv()] [, barIndex] )?
    2. How can I define a starting point for the lookback "length" value in the code so it plots the LR for say a length of 30 starting 25 bars back?

    I would like to modify the "customLinearRegression.efs" found in the ...\Formulas\EFS 2 Custom subdirectory so that it displays the linear regression lines starting from a set # of bars back (i.e., -20) and draws the LR lines for a specified length, say 25.

    The following code from the efs doesn't seem to have a starting point.

    xUpLR = upperLinearReg(Length, StdDev,eval(Source)());

    The "eSignal EFS Developer's Reference" allows for "barIndex" to be added as the last parameter of the above code but it caused an error message.
    It seems that when a "barIndex" is added to the end of the above code (see next two lines of code as my example) it returned a null value.

    xUpLR = upperLinearReg(Length, StdDev,eval(Source)(),25);
    or
    xUpLR = upperLinearReg(Length, StdDev,eval(Source)(),-25);

    Thank you for any help

    Comment


    • #3
      Alex,

      Thanks for the reply. The function of the "barIndex" is clear now.

      What I meant in the second question was:

      I would like to plot a linear regression line like I can using the LR button in the "Line Toolbar" menu but via efs. In other words, select a range say from barindex -30 through barindex -15 only.

      As I understood your answer (2) below, upperLinearReg(...) etc always uses the most current price as the end point.

      So, maybe in the old efs versions I will find a raw efs formula that allows me to input the start and end index bars as variables. I'll keep looking for said formula.

      Again, thanks for your continued help.

      Wayne

      Comment


      • #4
        waynecd
        You are welcome

        As I understood your answer (2) below, upperLinearReg(...) etc always uses the most current price as the end point.
        That is correct
        Alex


        Originally posted by waynecd
        Alex,

        Thanks for the reply. The function of the "barIndex" is clear now.

        What I meant in the second question was:

        I would like to plot a linear regression line like I can using the LR button in the "Line Toolbar" menu but via efs. In other words, select a range say from barindex -30 through barindex -15 only.

        As I understood your answer (2) below, upperLinearReg(...) etc always uses the most current price as the end point.

        So, maybe in the old efs versions I will find a raw efs formula that allows me to input the start and end index bars as variables. I'll keep looking for said formula.

        Again, thanks for your continued help.

        Wayne

        Comment

        Working...
        X