PureBytes Links
Trading Reference Links
|
It IS a general LSF solution ...
Regarding why I used the range -1 to +1, I answered this in my
previous response.
There is NO weighting.
--- In amibroker@xxxxxxxxxxxxxxx, "tomy_frenchy" <michel_b_g@xxx>
wrote:
>
> Hi,
>
> Ok I finally finded how it works. But the algorithm is just for
> polynomial fitting and is not a general function least square
> fitting.
>
> For those who need some explanation :
> Least Square Polynomial Fitting:
> http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
> Gaussian Elimination:
> http://mathworld.wolfram.com/GaussianElimination.html
>
> But just one thing i find strange in your formula is the range [-
> 1;1] for X (the time). I try to change GE_XBegin to "0" so the
range
> start from 0.
> On the graph, it is the same thing but it differs at the 5,6,7 and
8
> orders it seems.
>
> So why this range [-1;1] ? And do you try weighted least square
> polynomial fitting by weighted it by the volume or inverse of
> volatility ? (maybe the range [-1;1] is to weight the older and
> newest value of the price ?)
>
> For now i work on basic prediction based on this :
> http://www.duke.edu/~rnau/411avg.htm
> Maybe it could help for channel predicted (a DEMA can provide a
> trand prediction and so a straight channel can be created from
this).
> Just the trend prediction here :
>
> //----------------------------------------
> SetBarsRequired(20000,20000);
>
> P = ParamField("Price field",-1);
> Periods = Param("Periods", 15, 2, 200, 1, 10 );
> Factor = 2/(Periods+1);
>
>
> bi = BarIndex();
> current_pos = SelectedValue( bi ) - bi[ 0 ];
> printf( "Position: " + WriteVal(current_pos) + "\n" );
>
>
> e1 = AMA( P, Factor );
> e2 = AMA( e1, Factor );
> data=2*e1-e2;
>
> prediction=0;
> a=2*e1[current_pos]-e2[current_pos];
> b=(factor/(1-factor))*(e1[current_pos]-e2[current_pos]);
> for (i=current_pos+1;i<BarCount;i++) {
> k=i-current_pos;
> prediction[i]=a+k*b;
> }
>
> result=IIf(bi>current_pos,prediction,data);
>
>
> Plot( result, "DEMA Prediction", ParamColor( "Color DEMA
> Prediction", colorCycle ), ParamStyle("Style") );
> //----------------------------------------------------
>
>
> Thanks.
> Mich.
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "tomy_frenchy" <michel_b_g@>
> wrote:
> >
> > Hello Fred,
> >
> > I am actually trying to better anderstand how work your polyfit
> > version, maybe to try to make other sort of fitting (exponential
> > fitting, inverse fonction fitting...).
> >
> > For the Gaussian elimination in VBScript, it is to solve the
> linear
> > equations via matrix resolution with gauss pivot.
> > But I don't anderstand the parameters you send in the gaussian
> > elimination fonction.
> >
> > It seems you scale the time axis with a ramp from -1 to 1. After
> tou
> > make ^2,^3,etc, of this scale axis.
> > My first question : why take the sum of the x^n (i.e LastValue(Cum
> > (.)) ) ? Some sum are null because of the symetry of the ramp [-
> 1;1].
> >
> > And for the price (Y) data, you multiply them by the ramp [-1;1]
> and
> > make them power of this ramp. Why ? And same thing, why make a
> > LastValue(Cum(.))?
> >
> > For now, it seems you fit the polynom by anchor it to his most
> > recent and older value on the range. The value in the middle are
> > less weighted. And you fit him by using average value of price
(so
> > the cum funtion). But maybe i am totaly wrong.
> > Do you try with the least square method or maximum correlation to
> > fit the polynome ? It is too much computer time consuming ?
> >
> > Hope you will light my head who is burning for now héhé : )
> > Thanks,
> > Mich.
> >
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, Fred Tonetti <ftonetti@> wrote:
> > >
> > > Andy,
> > >
> > >
> > >
> > > Can you describe in English what your AFL does ? ...
> > >
> > >
> > >
> > > I've been playing with a Trig Fit a la Claud Cleeton the steps
> for
> > which I
> > > would describe as follows ...
> > >
> > >
> > >
> > > 1. Optional - Normalize the input i.e. Data = log10((H + L) / 2)
> > >
> > > 2. Calc an arbitrary length ( Parameterized but 11 at the
> moment )
> > centered
> > > moving average ( CMA ) of the data
> > >
> > > 3. Calc a 1st order least squares fit ( LSF ) of the CMA over
> the
> > period
> > > desired ( from / to range marker )
> > >
> > > 4. Subtract the LSF points from the data points resulting in
> > detrended data.
> > >
> > > 5. Take an n-bar sampling of the detrended data. This array
> > with "holes" or
> > > "gaps" in it needs either to be compressed or have the "gaps"
> > filled ... I
> > > elected ( for the moment ) to calc a cubic spline to fill the
> gaps
> > (
> > > interpolation ) ...
> > >
> > > 6. Calc a LSF of the detrended data resulting in the coeffs for
> > the Trig
> > > equation Y = A Cos wX + B * Sin wX
> > >
> > > 7. Calc the correlation of the resulting sin wave to the
> original
> > detrended
> > > data.
> > >
> > >
> > >
> > > Repeat steps 5 & 6 varying n from 1 to ? looking for n where
the
> > correlation
> > > is the highest. This should yield the equation or data points
> > that most
> > > closely correlate to the detrended data.
> > >
> > >
> > >
> > > 8. Subtract the points in the sin wave from the detrended data
> > resulting in
> > > a modified detrended data.
> > >
> > >
> > >
> > > Repeat steps 5 - 8 looking for the next most significant
cycle.
> > This can be
> > > done repeatedly until overall correlation stops getting better
> and
> > usually
> > > results in 2 - 6 cycles ...
> > >
> > >
> > >
> > > See attached .
> > >
> > >
> > >
> > > The white line in the upper graph is detrended price .
> > >
> > > The alternating green / red line is the trig fit, in sample up
> to
> > the
> > > vertical line and out of sample projection afterwards .
> > >
> > > The lines in the bottom section are the individual cycles found
> in
> > the data.
> > >
> > >
> > >
> > > Sometimes the projections are almost clairvoyant . run time
> > however is
> > > anything but quick .
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > _____
> > >
> > > I am using the free version of SPAMfighter for private users.
> > > It has removed 8649 spam emails to date.
> > > Paying users do not have this message in their emails.
> > > Try SPAMfighter <http://www.spamfighter.com/go.asp?t=249> for
> > free now!
> > >
> >
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.27/517 - Release Date: 11/3/2006
|