I have not found a way. The SMA function can’t do it because it is limited to a 500 bar (~2 year) offset. LoopSum can’t do it either because it can only handle 50 iterations or so.
No I don’t think so, but I’m not familiar with how the factors work. I am trying to only include companies in my screen that are within x% of their 10 year average price.
I think loopsum , even with 50 iterations limit, works pretty well. THese are companies within +/- 5% of their 10 year average : 50 samples, 50 bars apart for a total span of 2500 bars which is approx 10 years.
setvar(@avg,loopsum(“close(ctr)”,50,0,50,true)/50) // note the last parameter true to not skip NAs (companies with less than 10y)
between(close(0)/@avg,0.95,1.05)