How can I code 'days from lows lo' and 'days from high's high'

I need to find 'Days since high's high' and 'Days sinc lowest low' in a tim window.

by using 

HIGH = HHV(21)

I will get highest high value achieved in last 21 sessions. I dont want that. what I want is,

say highest high appeared 4 days back, then I need an equation which will give me '4' as an answer.

I am trying to code following

100- (days sing lowest low in last 100 days)

10 - ( days since highest high in last 100 days)

example, if lowest low of nifty withing last 100 tradng sessions occured 15 trading sessions back, in that case my equation should return me ( 100- '15')

For the above given condition it is not possible as per your required output, you can refer on the OHLC values or LAST with LTP with the tradescript.