Hello,
i’m trying to code a screener which finds stock who rise x consequent years for y % per year.
i cannot seem to find the right way. one way could be to compare week 0 with week 52, then week 52 with week 104, then week 104 with week 156 etc. but that limits me because the max of Close is 254? How to get passed this limit? Can you do something with month or year?
Other thing is that i could compare the first Close of a year with the last close of a year, but how to get that?
my code for now is like this:
// example screener code
p = 37 // how many percent
j = 4 // how many years?
//
//
p = p + 100//150 = + 50%
timeframe(weekly)
yearStartWEEKNR=52
yearStopWEEKNR=0
yearsOK = 0
FOR i = 0 to j-1 DO
yearStart=Close[yearStartWEEKNR]
yearStop=Close[yearStopWEEKNR]
IF ((yearStop*100)/yearStart>p) THEN
yearsOK=yearsOK+1
ENDIF
IF not (i+1 = j) THEN
yearStartWEEKNR=yearStartWEEKNR+52
yearStopWEEKNR=yearStopWEEKNR+52
ENDIF
NEXT
voldoet = 0
IF (yearsOK = j) THEN
voldoet = 1
ENDIF
c1=voldoet>0
screener[c1] (yearsOK as "yearsOK")
No, ProScreener does not support MONTHLY and YEARLY TF’s.
So 254 weeks is the maximun lookback period you can have.
and is there any other possibility?
Other thing is that i could compare the first Close of a year with the last close of a year, but how to get that?
Does your code above work?
If No, then can’t you do something with barindex using 1 52 104 156 208 254 to check for x% rise each year over a 5 year period?
Doesn’t have to be exactly 5 years / 260 weeks?
can you help me how the barindex could be of any help?
how can i calculate and show % raise on 0 52 104 156 208 260 etc?
Needs coding but to give x% change over 5 years …
(Close at barindex 254 + x%*Close at barindex 0) >= (Close at barindex 0)