Stock Percentile Measure

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #14727 quote
    deletedaccount14122020
    Participant
    New

    Hello Nicolas,

    I’m currently working on a couple of new indicators which I will send to ProRealCode when completed. I’m struggling with a part of my code and was wondering if you could advise.

    What I want to do is this:

    I want to know how many times the current CLOSE is higher than the previous 180 days CLOSES expressed as a percentage.

    Example using the last four days only : Last previous days CLOSE 10, 10, 15, 20

    Todays CLOSE is 18. Therefore this beats the previous four closes 3 out of 4 = 75%

    Hope this makes sense and thanks in advance

    #14756 quote
    Nicolas
    Keymaster
    Master
    You can easily count if a condition is true with a summation of this condition, like this:
    currentclose=Close
    
    count = SUMMATION[180](currentclose>close)
    
    ratio = count/180
    
    return ratio 
    Didn’t test it, should work as is. You’ll get a ratio here.
    #14780 quote
    deletedaccount14122020
    Participant
    New
    Nicolas, Thanks for your reply however I cannot get this to work as per your code. Example using just 5 periods back in time. Today’s close is 39.11, last 5 days are 38.33, 38.90, 38.98, 38.08, 38.54. Todays price is therefore beating the previous 5 days a 100% of the time. The code produces 60%. I also had to change the currentclose to close[1] as just close produced zero values. I’m not running real time just 1 day delayed currentclose= Close [1] count = SUMMATION[5](currentclose>close) ratio = count/5 return ratio   Many thanks
    #14783 quote
    Nicolas
    Keymaster
    Master
    Ok, try this instead:
    currentclose= Close
    
    count = SUMMATION[5](currentclose>close[1])
    ratio = count/5
    
    return ratio
    #14947 quote
    deletedaccount14122020
    Participant
    New
    Hello Nicolas, Thanks for the follow up. I think this code is looking at the current close and the previous close every day for each SUMMATION value and presenting a value. What I’m trying to achieve is some code where the current close is always the latest value and it checks this value against the close on all the previous values (as defined in the SUMMATION line) and produces a count. Do you think I’m correct here or have I got my thinking wrong? Many thanks
    #14948 quote
    Nicolas
    Keymaster
    Master
    The last code I gave you should do what you need. Because the code store the current close at line 1 and then make a summation of how much condition tested return true.
    #14950 quote
    deletedaccount14122020
    Participant
    New
    OK, got it, many thanks Nicolas
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Stock Percentile Measure


ProBuilder: Indicators & Custom Tools

New Reply
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by deletedaccount14122020
9 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/11/2016
Status: Active
Attachments: No files
Logo Logo
Loading...