Highest/lowest code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #54518 quote
    robdavrobdav
    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
    robertogozzirobertogozzi
    Moderator
    Legend
    // 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
    robdavrobdav
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    Replace line 8 with:

    HighestPrice = Max(close[i],HighestPrice)

     

    robdav thanked this post
    #54556 quote
    robdavrobdav
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    // 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
    robdavrobdav
    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 robdavrobdav
8 years, 9 months ago.

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