Help – Previous Hourly High/Low (Intraday)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #94579 quote
    vetrader
    Participant
    Average

    Hallo,

    I need help for previous hourly high/low. The code below doesn’t show the correct high/low for the second hour after opening – tried with Futures and Stocks. It is also strange that the plot has to be moved at return with hourlyhigh [1]. Everything else seems to work fine. Please have a look…

    Best regards

    //Previous Hourly High/Low
    once hourhigh=undefined
    once hourlow=undefined
    
    hhigh= high[0]
    hlow= low[0]
    
    if Hour <> Hour[1] then
    hourhigh = Highest[BarIndex – lastHourBarIndex](hhigh)
    hourlow = Lowest[BarIndex – lastHourBarIndex](hlow)
    lastHourBarIndex = BarIndex
    if Day <> Day[1] then
    hourhigh = hourhigh[1]
    hourlow = hourlow[1]
    endif
    endif
    
    return hourhigh[1] coloured(0,0,0) style(line,1) as “Prev Hour High”, hourlow[1] coloured(0,0,0) style(line,1) as “Prev Hour Low”
    #94580 quote
    robertogozzi
    Moderator
    Master

    To write code, please use the <> “insert PRT code” button, to make code more readable. Thank you.

    #94586 quote
    robertogozzi
    Moderator
    Master

    Try this one:

    //Previous Hourly High/Low
    defparam calculateonlastbars=1000
    if OpenHour <> OpenHour[1] then
       PreviousHigh = hourhigh
       PreviousLow  = hourlow
       hourhigh = 0
       hourlow  = 999999
    endif
    hourhigh = max(hourhigh,high)
    hourlow  = min(hourlow,low)
    return PreviousHigh coloured(0,0,0) style(line,1) as "Prev Hour High", PreviousLow coloured(0,0,0) style(line,1) as "Prev Hour Low"
    Finning thanked this post
    #94614 quote
    vetrader
    Participant
    Average

    Thanks for the reply. Is there a solution without “defparam calculateonlastbars”, because this has also an influence if this code is part of a script with other calculations??

    #94620 quote
    Nicolas
    Keymaster
    Master

    The solution is to remove that line, it only limits the calculation for that bars quantity, that’s all.

    robertogozzi thanked this post
    #94681 quote
    vetrader
    Participant
    Average

    Works fine – Thanks!

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

Help – Previous Hourly High/Low (Intraday)


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
vetrader @vetrader Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by vetrader
6 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/25/2019
Status: Active
Attachments: No files
Logo Logo
Loading...