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

TS2000 Bug Report - EL - Error with NumericRef



PureBytes Links

Trading Reference Links

There are times when values passed by reference to functions do not
contain the correct results. Here is a simple case to demonstrate this.

Background. For several months I had been using a function to calculate
several numbers I use frequently. Then suddently, some indicators
displayed correctly, while others did not. So I stopped using the
function, and stopped using NumericRef completely for new projects.
Since old indicators were ok, I didn't change them.

Today I altered an indicator that used a function that used NumericRef,
and my price bands suddenly displayed as flat lines! Checking the new
code, I discovered that NumericRef works fine, so long as you don't
refer to an old value of the variable. (Even though the code compiles
fine, I thought there might be a NumericSeriesRef keyword. But I can't
find one, and there's no need for one.)

I created a minimal case for your inspection (attached). Note that if
you comment out the code that refers to the previous value of the
variable, the indicator displays correctly. Further note that the error
occurs even when the code is not executed. And it doesn't matter if the
function storage is set to "simple" or "series".

Regards,

/Greg

{ 
BUG REPORT: Keywords: TS2000, NumericRef

This demonstrates an error with passing values by reference. 

The 'testbug' function is called twice with the same parameters,
expecting the same result for each.

The results are plotted. If the values are identical, the color 
of the second plot (cyan) will show. If they are different, the
color of the first plot (red) will also show.
}

{---------------------------------------------------------}
{ Indicator: TestBug }

var: upper1(0);
var: upper2(0);

value1 = testbug(h, upper1);
value2 = testbug(h, upper2);

{ indicator displays correctly if the following section is
commented out }
{}
if false then
	value1 = upper1[1];
{}

plot1(upper1,"",red,default,1);
plot2(upper2,"",cyan,default,1);

{---------------------------------------------------------}
{ FUNCTION - TestBug }
input: price(numericseries), upper(numericref);

upper = price + 1;
testbug = price;
Attachment Converted: "f:\eudora\attach\testbug.ELS"