Hi All, Pls can somone help with how to get the highest highs and lowest lows of the previous years? i have this code but not sure why trying to check if the current weeks bar close is higher than the last year’s highest high doesn’t work all the time?. I’m new to ProRealTime and ProRealCode… 🙂 .
TIMEFRAME(WEEKLY)
IF YEAR = YEAR[1] THEN
Wk52High = Highest[52](High[1])
con7 = Close >= Wk52High
ENDIF
The code you made is not compatible with ProBuilder, TIMEFRAME keyword is only available for ProScreener.
This is the code of an indicator that can give you the last year high:
If Year<>Year[1] then
yearlyHigh = Highest[BarIndex - lastYearBarIndex](High)[1]
lastYearBarIndex = BarIndex
endif
return yearlyHigh
@Nicolas, as always, THANK YOU!!!
Hi Nicolas, I wondered how could I adjust this code to only see the prior year levels rather than all the years H,L,C, and also how might I add text to the lines eg “PY High {price}” etc..
Many thanks
This code should only plot the last year High on the chart. Make sure you have sufficient displayed units for the code to correctly compute.
myline=undefined
If Year<>Year[1] then
yearlyHigh = Highest[BarIndex - lastYearBarIndex](High)[1]
lastYearBarIndex = BarIndex
yearTest = year
endif
if yeartest = CurrentYear then
myline = yearlyHIgh
endif
return myline
Sorry, I forgot the text, here is the modified code:
defparam drawonlastbaronly=true
myline=undefined
If Year<>Year[1] then
yearlyHigh = Highest[BarIndex - lastYearBarIndex](High)[1]
lastYearBarIndex = BarIndex
yearTest = year
endif
if yeartest = CurrentYear then
myline = yearlyHIgh
drawtext(" PY High {#myline#}",barindex,myline,dialog,bold,14)
endif
return myline
Great work Nicolas, thank very much for the quick response.