max draw down screener based on close
Forums › ProRealTime Deutsch forum › ProScreener Support › max draw down screener based on close
- This topic has 9 replies, 2 voices, and was last updated 6 years ago by jrh_han.
-
-
09/03/2018 at 10:41 AM #79619
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:
- 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
- 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
09/03/2018 at 12:38 PM #7963309/03/2018 at 12:59 PM #7963709/03/2018 at 2:28 PM #79649I 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.
09/03/2018 at 3:04 PM #7965709/03/2018 at 3:43 PM #79662Looking 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?
09/03/2018 at 4:05 PM #79664You can give a try with this screener:
screener123456789101112131415161718period = 50top = highest[Period](close)if top<>top[1] thentopbar=barindexbot=1000000endifbot = min(bot,close)if topbar>0 thenmaxspread=max(maxspread,(top-bot)/top*100)endiftest = maxspread>0screener[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:
indicator123456789101112131415161718defparam calculateonlastbars=254period = 50top = highest[Period](close)if top<>top[1] thentopbar=barindexbot=1000000endifbot = min(bot,close)if topbar>0 thenmaxspread=max(maxspread,(top-bot)/top*100)endifreturn maxspread09/04/2018 at 9:41 AM #7970809/04/2018 at 12:31 PM #7973809/04/2018 at 2:02 PM #79758 -
AuthorPosts
Find exclusive trading pro-tools on