Hi,
I have been trying to figure out how I can receive the period of the highest price if I consider a look-back period of, lets say 60 days. For example, if the price peaked 26 days ago, I want to receive the integer ’26’.
Thanks,
Simon
A solution would be to use a FOR / NEXT loop to find the previous bar that made the highest high in the last X bars.
You can find an example to build this kind of loop in our online documentation : https://www.prorealcode.com/documentation/for/
Let me know if you need more support!
Thanks for the feedback Nicolas,
This is the FOR-loop I managed to write:
Value=0
for i=1 to 30 do
if (close[i] > close[i-1] and close[i] > close[Value]) then
Value=i
else
Value=Value
endif
next
return Value
I will be using it for the look-back period to determine divergence patterns for OBV, MACD etc.. Although there may surely be several other applications. If anyone has more applicable ideas I am all ears!