Linear regresion may have less delay (all filters have delay) ... but you may 
choose to use MA, EMA, Linear Regression etc ...

If it seems like they all work ... then it does not matter. Try them .. you may 
get better results with one vs another. LR may allow you more statistical 
analysis, but I doubt you really want to make a big case out of this .. your 
application seems pretty straight forward....
  ----- Original Message ----- 
  From: Louis P. 
  To: [email protected] 
  Sent: Friday, September 05, 2008 4:33 PM
  Subject: Re: [amibroker] How to calculate a slope % with Rsquared without a 
loop?


  Hmm... BTW, what's the difference between a simple MA and a Linear 
regression... From a practical point of view?  They look very much alike when 
plotted!

  Thanks again!

  Louis


  2008/9/5 Louis P. <[EMAIL PROTECTED]>

    @Tomasz: I plotted this code on a 2-minute chart, and unfortunately half 
the result was 1.#INF  On a daily chart, however, got results between 0 and 2.  
Still wondering how to use this stuff, but thanks anyway.

    @Ara: I will work on your step 4 and 5.  I know nothing about how to use 
LinearReg so that will be lot of fun I guess.  But that's a good place to start 
I believe and thank you for your help.  I just don't know yet how to 
incorporate the linear reg and the C<0.9*HHV part to be honest.  But I will 
try...


    Thanks,

    Louis


    2008/9/5 Ara Kaloustian <[EMAIL PROTECTED]>


      I think the best solution would come from linear regression ... along 
with some help from smoothing perhaps.

      The concept would be that you first qualify a setup.
      Exapmle: 
      You want 10% drop from HHV in a particular amount of time ... maximum 
number of bars. (MinBars to MaxBars)

      1. Close < 0.9 * HHV(High,Maxbars);       // 10 % drop in less then 
Numbars bars
      2. BarsPast = HHVBars(High,Maxbars);  // Bars since HHV
      3. MinBars < BarsPast;                          // Insure that a minimum 
number of bars since HHV
      4. Draw regression line - Plot(LinearReg(array,period) .... ) 
      5. Evaluate slope of regression line
          slope = RL - Ref(RL,-1) /  Ref(RL,-1);   //  Slope at any point on 
the line
      6. You can decide how to alternately evaluate to slope .... max or min 
slope value ...etc

      You may also use a smoothed price array instead of actual prices by using 
price = (H+L+C+O) / 4 or (H+L) / 2 . 

      Hope this gets you closer to your objective.

        ----- Original Message ----- 
        From: Louis P. 
        To: [email protected] 
        Sent: Friday, September 05, 2008 11:00 AM
        Subject: Re: [amibroker] How to calculate a slope % with Rsquared 
without a loop?


        Hi,

        @Joe Landry: Thanks for the tips.  I'm not sure how the K-ratio can 
help on this, but if it can help...

        @Ara: I'm sorry if what I said was not clear.  What I want to do is to 
calculate a % pullback from a HHV of a stock but I want the slope to be 
"smooth", that is, I am not happy to see a 5 or 10% pullback but would like to 
see a 5 or 10% pullback with a particular slope inclination.   That is: if the 
stock dropped 10% in a day is not the same as if it quietly lost 0.5% for 20 
days (would not be exactly 10%, but this is an image).  You understand what I 
mean?  I want the slope to be as smooth as possible with a particular inclation 
%.  Is this possible?

        Thanks,

        Louis




        2008/9/5 Ara Kaloustian <[EMAIL PROTECTED]>


          Louis,

          I am not quite sure what you mean by "a smooth slope".

          Do you want to have a plot of prices that are smoothed ... as you 
would gt with a filter??

          OR do you want a computed value of slope at some particular point? 
... if so at what point ... or do you want a plot of the slope .... etc 

          If you can be moe specific that would be halpful!

          A



            ----- Original Message ----- 
            From: Louis P. 
            To: [email protected] 
            Sent: Friday, September 05, 2008 8:41 AM
            Subject: Re: [amibroker] How to calculate a slope % with Rsquared 
without a loop?


            Hi,

            Linear function is my big problem.  I'm so weak using that.  What 
is the difference between using this and doing it the other way?

            BTW, how would you set the number of bars in the current:


            HHVBars(Var,period); // Find number of bars - distance from HHV to 
current bar
            %slope = ((Highest high - currentclose) / Highest high) / number of 
bars * 100;

            Thanks,

            Louis




            2008/9/4 Ara Kaloustian <[EMAIL PROTECTED]>


              You can also use linearray to draw a stright line from HHV to 
current point.

              Look up LinearReg function
                ----- Original Message ----- 
                From: Ara Kaloustian 
                To: [email protected] 
                Sent: Thursday, September 04, 2008 10:37 AM
                Subject: Re: [amibroker] How to calculate a slope % with 
Rsquared without a loop?


                Try this:

                HHV(Var,period);   // find value of highest high
                HHVBars(Var,period); // Find number of bars - distance from HHV 
to current bar
                %slope = ((Highest high - currentclose) / Highest high) / 
number of bars * 100;

                You may choose to define slope in a different way, but this is 
the basic structure

                A
                  ----- Original Message ----- 
                  From: Louis P. 
                  To: [email protected] 
                  Sent: Thursday, September 04, 2008 9:34 AM
                  Subject: Re: [amibroker] How to calculate a slope % with 
Rsquared without a loop?


                  Hi,

                  Thanks for your response.  I should have said I want to 
calculate a slope from a high point; I'd like to get a smooth slope from a 
HHV... How would you do that?

                  Thanks a lot!
                  Louis


                  2008/9/4 Ara Kaloustian <[EMAIL PROTECTED]>


                    %slope = (variable - Ref(Variable,-x) ) / Ref(Variable,-x) 
* 100;
                      ----- Original Message ----- 
                      From: Louis P. 
                      To: [email protected] 
                      Sent: Thursday, September 04, 2008 9:20 AM
                      Subject: [amibroker] How to calculate a slope % with 
Rsquared without a loop?


                      Hi,

                      I was wondering how to calculate the % of a slope without 
doing any loop.  Anybody has any idea?

                      Thanks,

                      Louis











   

Reply via email to