[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cycle Length



PureBytes Links

Trading Reference Links

I'm sorry .. I meant to say that I want the sum of the price CHANGES to = 0 .. I tried this:
Inputs:Price(numeric),Max(numericsimple);

Vars:len(1),Min(1000),Save(10);

 

For Len=5 to Max begin

            Min=Summation(Price-Price[1],len);

            If AbsValue(Min)<Save then begin

                        Cyclelen=len;

                        Save=Min;

                        end;

            Len=Len+1;     

  end; ..

I'm close but this doesn't work .. 


----- Original Message ----- 
From: "Gary Fritz" <fritz@xxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Wednesday, January 07, 2004 9:51 AM
Subject: Re: Cycle Length


> > I thought I'd try to use the ehlers cycle length idea to create a
> > varying term oscillator .. so the idea is to find the number of
> > periods you have to go back in time until you reach the condition
> > where the sum of the closes or the sum of (high+low)/2 =0 .. 
> 
> Assuming you're looking at price when you're doing this, the sum 
> of closes and the sum of (H+L)/2 will **NEVER** approach zero.  
> They are all positive values, so the sums will all be positive.  
> You need a "price" that oscillates around zero.
> 
> One option, as Gary Funck mentioned, is to detrend the data.  
> Another is to use the slope of price instead of price itself, but 
> you still might want to detrend the data to take out strong 
> moves.  Otherwise a strong move will skew your cycle-length 
> calculations.  (I.e. in a strong up-move the slope might stay 
> positive even though there are clear cycles in the uptrend.)
> 
> You could use LinearRegSlope(Price, LRSlen) as your price proxy.  
> That will cross above and below zero as the price moves up and 
> down.  You could sum up the LRS values looking for a zero sum 
> like you were thinking, but it's probably simpler and more 
> accurate to look at zero-crossings.
> 
> So e.g. something like this (untested):
> 
> vars: LRS(0), LastCross(0), CycleLen(0);
> LRS = LinearRegSlope(Price, LRSlen);
> if LRS crosses over 0 then begin
>   CycleLen = CurrentBar - lastCross;
>   LastCross = CurrentBar;
> end;
> 
> That gives you the "cycle length" of the most recent "cycle," 
> where "cycle" is defined as the # of bars between places where 
> the price slope turns up.  That will change dramatically from 
> cycle to cycle.  If you want an average cycle length, you could 
> calculate an xaverage of the last N cycle lengths.  You should 
> calculate this yourself, e.g. something like
> 
> AvgCycLen = alpha*CycleLen + (1-alpha)*AvgCycLen;
> 
> rather than using xaverage(), because xaverage will calculate the 
> average value over the last N *bars*, not the last N *cycles*.  
> alpha = 2 / (Xlen + 1) for xaverage(price, Xlen).
> 
> If you want to detrend your data before calculating the LRS, you 
> can do something as simple as subtracting two xaverages.  E.g. 
> take a look at the oscillator you get with
> 
> LRS = LinearRegSlope(xaverage(Price,20)-xaverage(Price,15), 10);
> 
> BTW gaps will throw off this simple calculation.  You'll have to 
> get more clever to avoid that.
> 
> Gary
>