Highest/lowest code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #54518 quote
    robdav
    Participant
    Veteran

    Hi

    I know we can use highest https://www.prorealcode.com/documentation/highest/ and lowest https://www.prorealcode.com/documentation/lowest/  but does anyone have the code behind these please?

    Thanks

    Rob

    #54524 quote
    robertogozzi
    Moderator
    Master
    // 20-period HIGHEST
    //
    // This is not the official PRT code, but it shouldn't be much different
    //
    Periods      = 20
    HighestPrice = 0
    FOR i = 0 TO (Periods - 1)
       HighestPrice = Max(high[i],HighestPrice)
    NEXT

    Roberto

    robdav thanked this post
    #54533 quote
    robdav
    Participant
    Veteran

    Hi Roberto,

    Many thanks

    It’s close but not quite there. How could you apply this to the close like the PRT indicators are https://www.prorealcode.com/documentation/highest/

    Thanks again,

    Robert

    #54544 quote
    robertogozzi
    Moderator
    Master

    Replace line 8 with:

    HighestPrice = Max(close[i],HighestPrice)

     

    robdav thanked this post
    #54556 quote
    robdav
    Participant
    Veteran

    Hi Roberto

    Close does the job but how do I reverse this to get lowest please?

    Many thanks for you help.

    Thanks again

    Robert

    #54565 quote
    robertogozzi
    Moderator
    Master

    // 20-period LOWEST
    //
    // This is not the official PRT code, but it shouldn’t be much different
    //
    Periods         = 20
    LowestPrice = 999999
    FOR i = 0 TO (Periods – 1)
    LowestPrice = Min(close[i],LowestPrice)
    NEXT

    robdav thanked this post
    #54596 quote
    robdav
    Participant
    Veteran

    Many thanks Roberto, gives exactly the same results as the PRT code so thank you again.

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

Highest/lowest code


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
robdav @robdav Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by robdav
8 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/02/2017
Status: Active
Attachments: No files
Logo Logo
Loading...