(Testet with 5min resolution timeserie)
The output of first code is ok:
BarCount set to 1
BarCount:
1.00
CurrentBat:
1.00
BarCount:
2.00
CurrentBat:
...
but the second output is:
(for loop, added at end of code 1)
BarCount set to 1
BarCount:
1.00
CurrentBat:
1.00
BarCount set to 1 <-Called second time, why !?
BarCount:
1.00
CurrentBat:
1.00
BarCount:
2.00
CurrentBat:
2.00
BarCount:
...
it look like that first bar was evaluted twice, when using for loop with data reference in the past ?
IntraBarPersist of BarCount have not influance of this behavior.
It hapend oftem that in code where i use for loop with reference of past data the code is starting from begin some times, exampel evaluting first 100 bars it start from first bar again and so on ...
code #1:
Code: Select all
variables:
IntraBarPersist BarCount(0),
ii(0);
if currentbar = 1 then begin
print("BarCount set to 1");
BarCount = 1;
end else
BarCount = BarCount +1;
print("BarCount:");print(BarCount);
print("CurrentBat:");print(currentbar);
Code: Select all
variables:
IntraBarPersist BarCount(0),
ii(0);
if currentbar = 1 then begin
print("BarCount set to 1");
BarCount = 1;
end else
BarCount = BarCount +1;
print("BarCount:");print(BarCount);
print("CurrentBat:");print(currentbar);
for ii = 0 to 5 begin
if Close[ii] = 0 then //Dummy statment without functionality
Abort; //Dummy statment without functionality
end;