Screening performance since 1th day of year

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #6591 quote
    Andrea Tironi
    Participant
    Junior

    Hi.

    Is there a way to create a screener that ishows performance since 01.01?

    Thanks.

    Andrea

    #6602 quote
    Nicolas
    Keymaster
    Master

    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.

    year-performance-variation-of-an-instrument.jpg year-performance-variation-of-an-instrument.jpg
    #6938 quote
    Andrea Tironi
    Participant
    Junior

    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

    indicator.png indicator.png screener.png screener.png
    #6955 quote
    Nicolas
    Keymaster
    Master

    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")
    #6958 quote
    Andrea Tironi
    Participant
    Junior

    Great Nicholas!

    Thank you!

    #6959 quote
    Andrea Tironi
    Participant
    Junior

    Mhh sorry

    It give me close but i want to have perf in the screener.

    perf.png perf.png
    #6962 quote
    Andrea Tironi
    Participant
    Junior

    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")
    perf2.png perf2.png
    #6981 quote
    Nicolas
    Keymaster
    Master

    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")
    #7005 quote
    Andrea Tironi
    Participant
    Junior
    once start = close
    
    if(year<>year[1]) then
    
    start=close
    endif
    
    perf = (close-start)/start
    
    SCREENER [perf] (perf as "perf")

    It doesn’t work!

    code.png code.png
    #7020 quote
    Nicolas
    Keymaster
    Master

    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")
    #7023 quote
    Andrea Tironi
    Participant
    Junior

     

    Ok thanks!

    #7060 quote
    Andrea Tironi
    Participant
    Junior

    It’s all right!

    #10347 quote
    Andrea Tironi
    Participant
    Junior

    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

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

Screening performance since 1th day of year


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 12 replies,
has 2 voices, and was last updated by Andrea Tironi
9 years, 7 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 05/08/2016
Status: Active
Attachments: No files
Logo Logo
Loading...