Hi.
Is there a way to create a screener that ishows performance since 01.01?
Thanks.
Andrea
Hi,
Because ProScreener has a limitation of 254 bars lookback, I coded this little indicator to compute the performance of an instrument since the first day of the year.
once previousbar = 0
once hh = 0
once start = close
if(barindex>previousbar) then
previousbar=barindex
hh=MAX(hh,high)
var = (1-(start/hh))*100
varmax = MAX(var,varmax)
endif
if(year<>year[1]) then
hh = 0
varmax = 0
start=close
endif
RETURN varmax
You can include this one in your ProScreener with a CALL instruction or copy/paste the code in it and get the “varmax” variable to achieve what you want to do. Hope it helps.
Hi Nicholas.
Thanks for your help.
The indicator calculates the max year performance since start of the year.
You code is really helpfull, i use it:
once start = close
if(year<>year[1]) then
start=close
endif
RETURN ((close-start)/start)
And i have performancesincestartofyear indicator.
Then, i try to create the screener.
pssoy = call performancesincestartofyear
SCREENER(pssoy as "close")
But it doesn’t work. It gives nothing.
Can you help please?
Thanks.
Andrea
Hi Andrea,
This code will solve your issue I believe, I haven’t test it:
once start = close
if(year<>year[1]) then
start=close
endif
perf = (close-start)/start
SCREENER [perf] (close as "close")
Mhh sorry
It give me close but i want to have perf in the screener.
I try this but don’t work.
once start = close
if(year<>year[1]) then
start=close
endif
perf = (close-start)/start
SCREENER [1] (perf as "perf")
The screener is really screening ‘perf’ variable. But the list is populated with the actual close only.
Change the last line with this :
SCREENER [perf] (perf as "perf")
once start = close
if(year<>year[1]) then
start=close
endif
perf = (close-start)/start
SCREENER [perf] (perf as "perf")
It doesn’t work!
I know why.. Because sometimes start=0 it creates a ‘division by zero’ error in ProScreener and then it stops and don’t give any results.
Here is the fixed code:
once start = close
if(year<>year[1]) then
start=close
endif
if start=0 then
start=start[1]
endif
perf=((close-start)/start)
SCREENER [1] (perf as "perf")
The right code is:
once start = close
if(year<>year[1]) then
start=close[1]
endif
if start=0 then
start=start[1]
endif
perf=((close-start)/start)*100
SCREENER [1] (perf as "performancedainizioanno")
Previuos code don’t calculate first day of year.
I write it if someone need it.
Andrea