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

Re: error in TS LinearRegSlope function



PureBytes Links

Trading Reference Links

Benjamin Blanco wrote:
>Variables do not exist in the max bars back area.  MM1 should not be
>calculated until CurrentBar >= 6.  CurrentBar begins its count at one after
>the max bars back area.  Thus, the first time MM1 can correctly be
>calculated is at CurrentBar = 6.  We need four iterations ( Bar 6, 7, 8, 9 )
>of MM1 to correctly calculate MM2 for the first time.  Thus, MM2 should not
>be calculated until CurrentBar >= 9.  For example:
>
>AD = 100*(adv-dec)/(adv+dec+unc);
>if CurrentBar >= 6 then mm1 = LinearRegSlope(AD, 6);
>if CurrentBar >= 9 then mm2 = LinearRegSlope(mm1, 4);

The example from my previous message was around the middle of my data
range, where CurrentBar would be about 200 or so.  My MaxBarsBack is set
to 50 everywhere.  I don't think this is the problem.

>Here's a sample of what TradeStation 2000i calculated:
>
>date          AD        mm1       mm2
>1000627     10.70      4.73      2.78
>1000628     19.55      7.91      3.60
>1000629     -0.57     61.10     18.57
>1000630      0.29     18.32      9.39
>1000703     35.64    -14.95    -11.13
>1000705      1.13    -53.88    -37.82
>1000706      9.92    -90.12    -36.43

In the sample of output above, the first date corresponds to 6/27/2000.
The first date in my data is 9/1/1997.  Plenty of time to let things
settle.

I posted enough data above to calculate the last two values of mm1 and
the last four values of mm2.  mm1 is wrong, mm2 is correct (well, it's
*calculated* correctly, using the wrong values of mm1).

When I get home from work I will try implementing my own LinearRegSlope
function and experimenting with it.

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com