Signal test on average of all bars


I am doing a signal test what happens when price closes above all time average.

But i am not able to do it in signal test as all signals generated are based on test date average.

is there a way to modify the script that it uses average on that past date.

I am using below script.

$b = BARCOUNT();
v1 = MA(BARS=$b);
close() CrossesAbove LAST(V1)


Hi Deepak,

The BARCOUNT function counts the total number of daily values in a dataset, so it will always use the last value, and not the day-by-day count. BARINDEX() gives a running count but not when used in a bar variable situation, so I can’t think of a way that this can be done.