Give this a go:
barcount:=Cum(1);
movavg := Mov(C,20,S);
above := C>=movavg;
below := C<movavg;
crossabove := Cross(C,movavg);
crossbelow := Cross(movavg,C);
abovecount := barcount-ValueWhen(1,crossabove,Cum(1))+1;
belowcount := -1 * (barcount-ValueWhen(1,crossbelow,Cum(1))+1);
valuetoprint := If(above,abovecount,belowcount);
valuetoprint;
www.premiumdata.net