max draw down screener based on close

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #79619 quote
    jrh_han
    Participant
    New

    i like to screen shares and to sort those screened out by max draw down. but i fail to write the code as i have no idea how to realise the conditions as described below:

    maxdrawdown = (highest[…](close) – lowest[…](close)) / ( highest[…](close) * 100

    Conditions:

    1. the lowest…close must be occured later than the the highest…close – it shall represent the max. loss risk if the share was bought on highest close in that period
    2. as soon as a new highest…close is reached after a past lowest…close, this becames valid for the maxdrawdown calculation in combination with the lowest…close occured after this new high was reached etc.

    The criteria for sorting shall be the maxdrawdown occured during the last 254 days or 254 weeks.

    I would appreciate your support.

    Thanks in advance.

    Roger

    #79633 quote
    Nicolas
    Keymaster
    Master

    Ok, not so easy at first glance.. let me think of it so I can give a try to find you a relevant code.

    #79637 quote
    Nicolas
    Keymaster
    Master

    So basically, you want the max spread between the overall max price and minimum price occurred in the last 254 days? Or do you want to use periods to limit the found highest and lowest prices?

    #79649 quote
    jrh_han
    Participant
    New

    I attached an illustration with some examples.

    What I am looking for is a sorting criteria – i. e. max. DrawDown in the last year, max. Drawdown in the last month etc.

    This is not the period just to calculate highest[period](price) minus lowest[Period](price). In this period serveral DrawDowns may occur – and I just want for each share the biggest / smallest as sorting criteria.

    If its not getting clearer please let me know – than I try to explain it better.

    Chart-Example.jpg Chart-Example.jpg
    #79657 quote
    Nicolas
    Keymaster
    Master

    Visually, your chart is clear and I’ve understood what you are trying to get, but how do you find tops and bottoms? Basically what are the green and red arrows?

    #79662 quote
    jrh_han
    Participant
    New

    Looking on the chart I just recognise that it is visually clear to me, but I doesn’t believe, that there could be any mathematical description for it.

    So i try to simplify:

    Top = highest[Period](high)

    Low = lowest … (low) – AFTER the top AND before the next top = between current and next top.

    Any idea if this could be realised?

    #79664 quote
    Nicolas
    Keymaster
    Master

    You can give a try with this screener:

    period = 50
    
    top = highest[Period](close)
    
    if top<>top[1] then 
    topbar=barindex
    bot=1000000
    endif
    
    bot = min(bot,close)
    
    if topbar>0 then 
    maxspread=max(maxspread,(top-bot)/top*100)
    endif
    
    test = maxspread>0
    
    screener[test](maxspread)

    I used Close instead of high, because it was how you explained it the first time, you can change the price serie if you want to.

    And an indicator to confirm the calculation and see how and when the max spread between highest high and the low was found:

    defparam calculateonlastbars=254
    
    period = 50
    
    top = highest[Period](close)
    
    if top<>top[1] then
    topbar=barindex
    bot=1000000
    endif
    
    bot = min(bot,close)
    
    if topbar>0 then
    maxspread=max(maxspread,(top-bot)/top*100)
    endif
    
    return maxspread
    #79708 quote
    jrh_han
    Participant
    New

    Great – the indicator does exactly what I intended.

    But not so the screener. The screener just takes into account the “last” maxspread fromm current high to current low. The previous highs / lows are not taken into account.

    #79738 quote
    Nicolas
    Keymaster
    Master

    The screener does the same, always saving the highest maxspread, please verify on stocks that you have a live data subscription (not “End Of Day”). Bear in mind that ProScreener only have 254 bars of history available.

    #79758 quote
    jrh_han
    Participant
    New

    It works.

    Thx a lot

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

max draw down screener based on close


ProScreener: Marktscanner & Aktiensuche

New Reply
Author
author-avatar
jrh_han @jrh_han Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by jrh_han
7 years, 5 months ago.

Topic Details
Forum: ProScreener: Marktscanner & Aktiensuche
Language: German
Started: 09/03/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...