PureBytes Links
Trading Reference Links
|
I went a little further. I'd encourage you to send it to TJ. I
think that it may be a serious problem. I instrumented the code and
played with it a little. Using a ticker of DJ-30, my conclusion was
that a call to StochTransform with any of the reserved variables (O,
C, etc.) overwrote the variable that was used in the previous call.
Note in the example how StochDiff is overwritten. In traditional
languages, this type of thing is usually indicative of a stack
problem in the function processing.
Here's what I played with -
function StochTransform(array, period) {
local LowValue;
LowValue = LLV(array, period);
return 100 * (array - LowValue) / (HHV(array, period) -
LowValue);
}
Filter = 1;
Diff = Signal(12, 26, 9);
_TRACE(WriteVal(Diff, 8.3));
AddColumn(Diff, "DIFF BEFORE", 8.3);
StochDiff = StochTransform(Diff, 5);
// It looks like a call to StochDiff with Close as the first parm
wipes
// out the variable that was used in the last call to StochDiff
JunkIgnored = StochTransform(Diff, 14); // <<< BUT THIS DOESN'T
JunkIgnored = StochTransform(StochDiff, 14); // <<< AND THIS DOESN'T
//JunkIgnored = StochTransform(C + 0, 14); // <<< AND THIS DOESN'T
JunkIgnored = StochTransform(C, 14); // <<< ENABLING THIS CHANGES
Diff,WHY???
_TRACE(WriteVal(Diff, 8.3));
AddColumn(Close, "CLOSE", 8.3);
AddColumn(Diff, "DIFF AFTER", 8.3);
AddColumn(StochDiff, "STOCHDIFF", 8.3);
AddColumn(JunkIgnored, "JUNK", 8.3);
-- Bruce
--- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" <dmerrill@xxxx>
wrote:
> Thanks for checking it out Bruce, I appreciate it. The msg I posted
was a
> simplification of the more complicated code where I first found the
problem,
> and that was the last work I've had time to do on it. (That j.o.b.
thing...)
>
> Do I gather that you saw the same results I did? Puzzling, isn't it?
>
> Dave
> I was up early this morning and took at quick look at the problem
> that you found. Have you made any headway?
>
> -- Bruce
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" <dmerrill@xxxx>
> wrote:
> > I'm seeing a weird problem that I think may be the result of
> something I
> > don't understand about variable scoping. Check this out:
> >
> > ----------------------
> > function StochTransform(array, period) {
> > local LowValue;
> > LowValue = LLV(array, period);
> > return 100 * (array - LowValue) / (HHV(array, period) -
> LowValue);
> > }
> >
> > Diff = Signal(12, 26, 9);
> > StochDiff = StochTransform(Diff, 5);
> >
> > //JunkIgnored = StochTransform(C, 14); // <<< ENABLING THIS
> CHANGES Diff,
> > WHY???
> > //JunkIgnored = StochTransform(Diff, 14); // <<< BUT THIS
> DOESN'T
> > ----------------------
> >
> > First enter it into IB as given above, look at the chart, then
> enable the
> > first of the two commented out lines at the bottom. Notice that
> Diff (blue
> > histogram) changes drastically. Now enable the second one and
not
> the first,
> > and things go back to "normal".
> >
> > I don't get this at all. It seems like it must be due to
> interaction between
> > the two calls to StochTransform, and in fact, if you create a
copy
> of the
> > function called StochTransform2, and call that the second time,
no
> problem.
> > Guessing further from the fact that using the same value for
> the 'array'
> > parameter in both cases also prevents the problem, most likely
the
> conflict
> > is with the reuse of that formal parameter when the function is
> called the
> > second time.
> >
> > I've never seen this behavior before, and I don't understand it.
> Among other
> > things, if it's really true that you can't call the same
function
> more than
> > once without interactions like this, a lot of code I've written
> that I
> > thought worked, didn't. Or is there some simple stupid bug in
this
> test that
> > I'm missing?
> >
> > Ideas? Tomasz?
> >
> > Dave
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|