I am trying to identify the number of days since an event occurred in Pro Screener. i.e I want to identify a moving average cross over that occurred anytime within the previous (x) periods.
It seems that I need to use the Barindex function, but I don’t seem to fully understand the syntax to make it work properly. Can anyone provide some guidance for me??
BARINDEX just gives each candle an identifying number – it indexes them for ease of finding later. The first candle on a chart is 1 and the second is 2 right up until the latest candle which would be 500 if there were 500 candles on a chart.
So just save the BARINDEX value when a cross occurs and then BARINDEX minus that value tells you how many candles ago the last cross occurred.