PureBytes Links
Trading Reference Links
|
> While testing a strategy, I noticed some strange and unexpected
> signals.
Listening said:
> According to the help files, the LinearRegSlope Len parameter is
> a numeric simple type input.
> Numeric simple inputs limit you to a number that doesn't change on
> a bar-to-bar basis.
Not true. It just means you can't access previous values of the
input. For example, try running this code:
{ function foo }
inputs: bar(numericsimple);
vars: xx(0);
if mod(barnumber,2) = 0 then xx = xx + bar else xx = xx - bar;
foo = xx;
Pass it a changing value, like BarNumber, or something like that.
You'll see the input changes just fine.
In any event, Alex's code *doesn't* change the Len parameter, so that
wouldn't make any difference in this case anyway.
> The AD column is calculated correctly. However, the mm1 column is
> NOT the linear regression slope of the last 6 AD values. See that
> last mm1 value -90.12? It should be -0.22. The value previous to
> that, -53.88, should be 0.037.
Hm. I also get -0.22 and 0.037 if I calculate it in Excel.
> Oddly, the mm2 column is calculated correctly (using the incorrect
> mm1 values).
That's beyond odd. If the inputs are wrong, the outputs can't be
right. Your data sample is too short for me to check this -- I can
only generate 2 valid values of mm1, so I can't calculate mm2 -- but
something isn't right.
> Also, when I make an indicator to plot mm1, it plots
> with the correct values! In my strategy, however, the values are
> incorrect, and so are the buy/sell signals resulting from them.
The same code, in an indicator, plots the values you expect??
If you print the values in the system & the indicator, do they print
the same values?
Do you maybe have different MaxBarsBack in the system & indicator?
If this data series is near the beginning of the chart, I suppose
it's possible the calculations hadn't settled yet, or something like
that. But that shouldn't be an issue with LinearRegSlope. Hmmmm.
Gary
|