Hello all,
I want to make an indicator which is as follows: (((100- (number of periods since highest high))/100) * 100.
However, I cannot translate the “number of periods since highest high” to prt code.
Your help is much appreciated.
Thank you very much.
And best wishes,
Geraldo
First you have to define the number of previous bars you want to scan to find a “highest high”.
If you want the highest high of the last 100 bars you may write:
ONCE LookBack = 100
HighestHigh = -1
HighestBar = 0
FOR i = 0 TO LookBack
IF high > HighestHigh THEN
HighesetHigh = high
HighestBar = i
ENDIF
NEXT
At the end of which HighestHigh will hold the highest price found and HighestBar its bar ID, 0 to 100. So if it returns 23 you can reference that cadlestick with [23] (low[23], close[23,….).