Buy using "Cross" function

ma8 = MA(C, 8);
ma20 = MA( C, 20);
Buy = Cross (ma8,ma20);

I'm trying to capture the "cross" on the last bar but may scan returs crosses from the past?
How to program to get crosses on the last bar???

Either in Analysis>Range set to 1 recent bar, or
Add code to limit the buy to the last bar

Add first line

bi = barindex();// first line gives bar index

Buy= cross( your code ) AND bi == barcount -1;// selects cross on the last bar if it exists note barindex is zero based