Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

Find ATH and ATL

Sep 23, 2021 - 6:46 PM

Viewed 684 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/26338 COPY
  • hey guys im trying to get all time high and all time low, but the second one return always a zero? why? is based on low. i leave a pic of the code

    Catturssa.png

    This post was edited Sep 23, 2021 06:48PM
    1
  • Not sure why either
    Try this way

    // function to get all-time high
    get_all_time_high() =>
        h = 0.0
        h := barstate.isfirst ? high : high > h[1] ? high : h[1]
        h
    
    // function to get all-time low    
    get_all_time_low() =>
        l = 0.0
        l := barstate.isfirst ? low : low < l[1] ? low : l[1]
        l    
    
    // getting all-time high/low    
    h0 = security(syminfo.tickerid, 'M', get_all_time_high())
    l0 = security(syminfo.tickerid, 'M', get_all_time_low())
    
    // plotting
    plot(h0, offset=-9999999, color = color.blue, trackprice=true, linewidth=3)
    plot(l0, offset=-9999999, color = color.blue,  trackprice=true, linewidth=3)
    
    0
CONTENTS