How to adress last/next high/lowpoint

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #169977 quote
    fiboman3000
    Participant
    Junior

    Hello everyone,

    I wrote this simple code to detect all relevant highs and lows, which works fine. Now I want to analyze their relative position to detect ranges and trend periods.

    So I need to adress the next/last or 2nd, 3rd high or low to make further statements.

    How can I realize that using barindex?

    Thanks a lot in advance for any input

    cheers

    Jakob

    lp = low[4] <= lowest[10](low)
    hp = high[4] >= highest[10](high)
    
    if lp then
    DRAWSEGMENT(barindex, low[4], barindex[4], low[4])coloured(255,0,0)
    endif
    
    if hp then
    DRAWSEGMENT(barindex, high[4], barindex[4], high[4])coloured(0,222,0)
    endif
    
    return
    
    Bildschirmfoto-2021-05-19-um-13.48.47.png Bildschirmfoto-2021-05-19-um-13.48.47.png
    #170723 quote
    robertogozzi
    Moderator
    Master

    You have to use Arrays:

    $HIprice[0] = 0
    $HIbar[0]   = 0
    $LOprice[0] = 0
    $LObar[0]   = 0
    
    lp = low[4] <= lowest[10](low)
    hp = high[4] >= highest[10](high)
     
    if lp then
    DRAWSEGMENT(barindex, low[4], barindex[4], low[4])coloured(255,0,0)
    $LOprice[lastset($LOprice)+1] = low[4]
    $LObar[lastset($LObar)+1]     = barindex[4]
    endif
     
    if hp then
    DRAWSEGMENT(barindex, high[4], barindex[4], high[4])coloured(0,222,0)
    $HIprice[lastset($HIprice)+1] = high[4]
    $HIbar[lastset($HIbar)+1]     = barindex[4]
    endif
    
    IF lastset($HIprice) > 0 THEN
    Drawtext("●",$HIbar[lastset($HIprice)],$HIprice[lastset($HIprice)]) coloured(255,0,0,255) //Red
    ENDIF
    
    IF lastset($LOprice) > 0 THEN
    Drawtext("●",$LObar[lastset($LOprice)],$LOprice[lastset($LOprice)]) coloured(0,128,0,155) //Green
    ENDIF
    
    return
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

How to adress last/next high/lowpoint


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
4 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/19/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...