Alma Miranda,
I have added a homemade 'smoothness' indicator to Ian/Tomasz's
RSquared (it is a interesting comparison).
Run in an exploration and sort columns by R2 or SLR(StraightLineRatio)
to see that they report similar things.
The logic of SLR is "how long is a piece of string?"
I added every daily $move and compared that to the point to point
$Value as a ratio - it is not an abolute indicator - it only shows
relative smoothness - I tried % changes but that doesn't work.
Other candidates for smoothness that I can think of are StDev and
StandardError (the regression version?).
I have been a little bit interested ever since I studied Professor
John Prices techno-fundamental method (he picks stocks based
on 'smooth' earnings growth) - I figured 'smooth' charts might be a
TA surrogate for 'smooth' earnings and save the trouble of doing the
fundamental calculations.
http://www.conscious-investor.com/index.html
Here is the modified formula:
//F_RSquared
//Tomasz Janeczko
//Adapted by Ian Watts
//I have changed it slightly to use R * R instead
//of R^2 to speed up the calculation.
//The exploration aims to find stocks that are
//currently going up OR down relatively
//smoothly.
function RSquared(array, periods)
{
R = Correlation(BarIndex(), array,
periods );
R2 = R * R;
return R2;
}
Periods = 250;
R2 = RSquared(C, Periods);
LVR2 = LastValue(R2);
//Filter = LVR2 > 0.9;
Filter = 1;
AddColumn(R2, "RSquared",1.1);
/////////////////////////////////////////////////////////
//P_StraightLineRatio
//Periods = 250;
Change = abs(C - Ref(C,-1));
Total = Sum(Change,Periods);
StraightLine = abs(C - Ref(C,-Periods));
StraightLineRatio = Total/StraightLine;
Filter = 1;
//Filter = StraightLineRatio <= 30;
//Filter = BarCount == 1305;
AddColumn(StraightLineRatio,"SLR",1.1);
AddColumn(BarCount,"BarCount",1);
Plot(StraightLineRatio,"SLR",1,1);
Have fun,
brian_z
--- In amibroker@xxxxxxxxxps.com, "Ian Watts" <idw456@xxx> wrote:
>
> Brian
>
> The function was written by Thomasz and can be
> found here:
> http://www.traders.com/Documentation/
> FEEDbk_docs/Archive/122007/TradersTips/
> TradersTips.html#amibroker
>
>
> function RSquared(array, periods)
> {
> R = Correlation(BarIndex(), array,
> periods );
> R2 = R * R;
> return R2;
> }
>
> R2 = RSquared(C, NoPeriods);
> LVR2 = LastValue(R2);
> Filter = LVR2 > 0.9;
>
> I have changed it slightly to use R * R instead
> of R^2 to speed up the calculation.
>
> The exploration aims to find stocks that are
> currently going up or down relatively
> smoothly.
>
> All the Best
>
> Ian
>
> --- In amibroker@xxxxxxxxxps.com,
> "brian_z111" <brian_z111@> wrote:
> >
> > Ian Watts,
> >
> > How can I do that in AFL?
> > Have you seen the R-Squared formula at the
> AFL library - any comment
> > on that?
> >
> > Any hints greatly appreciated.
> >
> > Thanks,
> >
> > brian_z
> >
> >
> > --- In amibroker@xxxxxxxxxps.com, "Ian
> Watts" <idw456@> wrote:
> > >
> > > A method I use is to fit a least squares
> line
> > > to the last 20 or so bars. Then calculate
> R
> > > Squared and select the stocks with the
> highest
> > > values of R Squared.
> > >
> > > Regards
> > >
> > > Ian
> > >
> > >
> > > --- In amibroker@xxxxxxxxxps.com,
> > > "safetrading" <safetrading@> wrote:
> > > >
> > > > With every strategy I have used, I have
> > > always noticed that I get
> > > > whipsawed out more often with stocks that
> > > don't flow smoothly and
> > > > therefore have tried to create a filter
> that
> > > does nothing more than
> > > > find stocks which flow smoothly up and
> down.
> > > >
> > > > The best I have come up with is one that
> > > simply limits the number of
> > > > up and down fractals in a given time
> period.
> > > While this helps, it
> > > > does not really produce what I was hoping
> to
> > > get.
> > > >
> > > > Can anyone offer any help or suggestions
> with
> > > this?
> > > >
> > > > Thanks,
> > > >
> > > > Safetrading
> > > >
> > >
> >
>