My debugging test result in the picture attached
In the picture the var4 gives the result "5" (always the max countif() value possible) with custom local variable (see bottom right corner of the chart)
while the novar gives the result "4" (the correct countif() value) of the countif without the custom local variable.
The var4 related snippet
double var0 = High[0];
double var1 = Low[0];
double var2 = 15*TickSize;
bool var3 = var0 - var1 >= var2;
int var4 = CountIf(() => var3, BarsBack);
Draw.TextFixed(
this,
"testa",
"var4: " + var4 + "\t\n\n",
TextPosition.BottomRight,
Brushes.Green,
myFont,
Brushes.Transparent,
Brushes.Transparent,
0);
The novar related snippet
Draw.TextFixed(
this,
"testb",
"novar: " + CountIf(() => High[0] - Low[0] >= 15*TickSize, BarsBack) + "\t\n",
TextPosition.BottomRight,
Brushes.Green,
myFont,
Brushes.Transparent,
Brushes.Transparent,
0);
Why aren't the var4 and novar results matching?
How to make them match? Thanks

Comment