PureBytes Links
Trading Reference Links
|
> I'm sorry .. I meant to say that I want the sum of the price CHANGES
> to = 0 ..
OK, that works better. However try comparing it to that
detrended LRS I showed you:
LRS = LinearRegSlope(xaverage(Price,20)-xaverage(Price,15), 10);
The LRS signal is very similar to a 10-period summation of the
price changes, but much smoother and cleaner.
> I tried this:
> I'm close but this doesn't work ..
OK, looks like you're scanning to find the value of Len that
produces the minimum summation value. That's reasonable.
Looking quickly at your code I see two problems:
> Len=Len+1;
The for loop increments Len automatically. You don't have to.
So you're skipping every other value of Len. (Some languages
don't even let you touch the loop variable, to avoid errors like
this.)
Bigger problem: You want to find the summation value that's
closest to zero -- which would be the minimum absvalue of the
summation. You correctly test AbsValue(Min) in your if test, but
then when you save Min you DON'T take the absvalue. So if Min
is, say, -9, you'll save -9 and no smaller absvalue will succeed
in your if test. Change the line to "Save = absvalue(Min);" (or
change your if test to "if absvalue(Min) < absvalue(Save) ...")
and it might work better.
Gary
|