Variable Assignment is Distorting Values
Posted: Jan 28 2019
Hi guys,
Came across a weird issue where assigning a value to a variable seems to distort the past values of that value when these past values are referenced. The first batch of code below outputs values different from the values output by the second batch of code, and I have no idea why.
The second set of output values is the correct one, and the one that I want. However, it is SO much slower than the code in the first snippet above. Prohibitively slow in the grand scheme of things. It seems pretty weird that I shouldn't be able to assign this value to a variable and enjoy the speed and good coding convention that variable assignment offers without having to accept inaccurate values.
Can some please advise me on what to do?
Thanks a lot!
Came across a weird issue where assigning a value to a variable seems to distort the past values of that value when these past values are referenced. The first batch of code below outputs values different from the values output by the second batch of code, and I have no idea why.
Code: Select all
vars: Bandwidth(0,data4), BulgeLine(0), SqueezeLine(0), x(0);
Bandwidth = BollingerBandwidth(Close,20,2,-2)data4;
BulgeLine = Highest(Bandwidth,50);
SqueezeLine = Lowest(Bandwidth,50);
if date = 1181210 and time = 1126 then begin
print(date,time,"||",BulgeLine:0:4,"||", o data4,"||",h data4,"||",l data4,"||",c data4);
for x = 0 to 5-1 begin
print(x, ", ", [b]Bandwidth[/b][x]:0:4);
end;
end;
BollingerLESeconds = BulgeLine-SqueezeLine;
Code: Select all
vars: Bandwidth(0,data4), BulgeLine(0), SqueezeLine(0), x(0);
Bandwidth = BollingerBandwidth(Close,20,2,-2)data4;
BulgeLine = Highest(Bandwidth,50);
SqueezeLine = Lowest(Bandwidth,50);
if date = 1181210 and time = 1126 then begin
print(date,time,"||",BulgeLine:0:4,"||", o data4,"||",h data4,"||",l data4,"||",c data4);
for x = 0 to 5-1 begin
print(x, ", ", BollingerBandwidth(Close,20,2,-2)data4[x]:0:4);
end;
end;
BollingerLESeconds = BulgeLine-SqueezeLine;
The second set of output values is the correct one, and the one that I want. However, it is SO much slower than the code in the first snippet above. Prohibitively slow in the grand scheme of things. It seems pretty weird that I shouldn't be able to assign this value to a variable and enjoy the speed and good coding convention that variable assignment offers without having to accept inaccurate values.
Can some please advise me on what to do?
Thanks a lot!