tHiding( if(close > reference SimpleMovingAvg(length=21),1,0)) If the SMA(21) was less than the close of that bar it would print a point at the specified value. That would return the SMA value for that bar.
I'm not sure if I understood exactly what my reader wanted to do but here is one example of leveraging TOS studies.