PureBytes Links
Trading Reference Links
|
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/
|