What would be the algo for these formulas

X factor high =

 [  (( number of periods) -( number of periods since highest high))/number of periods] * 100

n = input from user

X factor Low =

 [  (( number of periods) -( number of periods since lowest low))/number of periods] * 100

the syntax for the Highest High value in tradescript is  example

LAST > HHV(14)

the syntax for the lowest low value is 

LAST < LLV(14)

you can define x by    SET X = (condition)

your condition is not clear.

suppose I chhised highest high for 10 days , it means stock made hightest high within 10 days like it made high 10 rs , nest day it made high 12 then it made high 14 , so it made highest high with in 10 days 3 times .
so graph would be logrithmic value of (log 7/10) * 100.