Historic RSI fetch using scanner

I am aware of the code to fetch the current candle RSI however can someone please tell me what is the code to fetch historic RSI? For example I need to compare if the RSI of 5th last candle was more than the last candle.