i add to watchlist in my scans using lastvalue(Buy) however if i set my N last quotations >1 then it will not work properly as the Buy signal could have been in a earlier bar. how can i detect the value of the N last quotations and check for Buy signals within the N last quotations and combine it with a if statement. for eg this is my code which i need to convert to use the N last quotations.
if((LastValue(Buy)==1 )) {
CategoryAddSymbol("",categoryWatchlist, wlnumber)
}
