Analysing ranges of data

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #231216 quote
    OllieB
    Participant
    Junior

    Hi,

    Can anyone please tell me the best way to analyse a dataset that doesn’t include the most recent, say, 5 days?

    For example, if I want to find the highest value in the previous 5 to 250 days (ie the last year, but excluding the most recent week), how do I do it?  highest(250) will include the most recent 5 days.

    The built in functions always seem to work on the premise of current candle to a value X candles away.  So highest(10) will look at the most recent 10 candles, but if I wanted to analyse candles 11-20, how do I do it?  Is there a way to introduce an offset, something like highest (5,10), which would start the analysis 5 candles back and analyse the 10 candles before the offset?

    Is there a range capability built into the functions, or will I have to build an array and analyse that?  Or is there a clever way (beyond me!) that can count candles?

    Any help as always is very much appreciated.

    Thanks.

    #231218 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    Assuming a real time PRT version (not the end of day version), and looking at 250 previous days (not including current day), we want the highest from 6th previous to 250th previous, then that’s a 245 day span, you create a variable “mydata” searching for highest within 245, and you look at the value it had 6 days ago, therefore without the need a new function:

    mydata=highest[245](high)
    
    myresult=mydata[6]

     

    to be added in your screener as we are in proscreener forum,

    or if you want to see it in an indicator too/instead, adding a final return line:

    return myresult as "highest between 6 days ago and 250 days ago"
    OllieB thanked this post
    #231219 quote
    OllieB
    Participant
    Junior

    Hi JC,

    Thank you for replying.

    Thats pretty clever, thanks.  I’ll give it a go!

    #231234 quote
    OllieB
    Participant
    Junior

    Hi JC,

    That’s great, it works.  And I understand it, so I have learnt something as well, thanks.

    Maybe you can help with a similar but slightly different problem.  If I have a range of data, say 20 values, how do I find which of those has the highest high?  So instead of returning the highest value, it returns which position in the range the highest value is at?

    something like:

    ReturnVal = position(highest[20])

    Thanks.

    #231256 quote
    JC_Bywan
    Moderator
    Master

    For this, you want to use the command highestbars, it saves you writing a for-next loop scanning past candles to check at what barindex was the highest. The result is “how many bars ago”:

    myresult= highestbars[20](high)

    In case you want the corresponding barindex number instead of how many bars ago, you can get it with:

    mybar= barindex-myresult
    OllieB thanked this post
    #231257 quote
    OllieB
    Participant
    Junior

    Thats awesome, thanks JC.  You are a master!

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

Analysing ranges of data


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
OllieB @ollieb Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by OllieB
1 year, 11 months ago.

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