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

Re: Cycle Length



PureBytes Links

Trading Reference Links

On Oct 3, 12:31pm, Carroll Slemaker wrote:
> Subject: Re: Cycle Length
> I generally prefer odd numbers because the middle value, 11 in your case, is
> the exact mid point.  If you were to use a cycle length of 20, the midpoint
> would be 10.5 (equal number of values - bars - above and below the mid
> point) and you would then have to fudge by adding or subtracting 0.5 to
> reach the nearest whole integer.  (Note that using 10 as the "mid point" for
> 20 gives 9 bars below and 10 bars above, not symmetrical.)

Another question is whether to use trading days, or calendar days
on EOD data?  From a fundamental point of view (day of week, day of
month effects), there's something to be said for using calendar days
instead, which effectively establishes a variable number of trading
days in the lookback.

If you want to experiment with using calendar days in the lookback,
here's a function that I wrote, and posted here a year/so ago.

{
  function: calbar - return the number of trading bars equivalent
  to a calendar day lookback of 'N'.  Uses linear interpolation
  to speed up the search.
  
  For example, calbar(7) generally returns 5, unless the trading week
  had fewer days do to holidays/outages etc.

  As written, works on end-of-day data only.

  Author: Gary Funck <gary@xxxxxxxxxxxx>, August 1999
}
input: N(numericsimple);
var: x(0), y(0), xl(0), yl(0), xh(0), yh(0), yn(0), cnt(0);
xl = 0;
yl = datetojulian(Date[N]);
xh = N;
yh = datetojulian(Date[0]);
yn = yh - N;
x = IntPortion(xl + (xh - xl) * (yn - yl) / (yh - yl));
y = datetojulian(Date[N - x]);
{ print(N, yl, yh, yn, x, y); }
cnt = 0;
while ((y <> yn) and (x <> xl) and (cnt < 10)) begin
    { print(cnt, x, y, xl, yl, xh, yh); }
    if y <= yn then begin
        xl = x;
        yl = y;
    end else begin
        xh = x;
        yh = y;
    end;
    x = IntPortion(xl + (xh - xl) * (yn - yl) / (yh - yl));
    y = datetojulian(Date[N - x]);
    cnt = cnt + 1;  
end;
calbar = N - x;