Search code examples
arrayspine-script

the lowest low of some days


I'm trying to find a way to get a signal-point on the chart everytime the bar is a new 15-days low.

Thanks for help!

//@version=5
indicator('15-Days-Low', overlay=true)

bars_back = input(15)

ll = ta.lowest(bars_back) //15-d-low
tl = ta.lowest(source=low, length=1) //todays low
lb = ta.lowestbars(bars_back)  //lowest bar since when? (negative number)

plotchar(tl < ll, char='•', color=color.fuchsia, size=size.tiny, location=location.belowbar)

I tried to find the lowest low of the last 15 days, compare it to the low of today, and plot a char if the todays low is the lowest of the last 15 days.


Solution

  • ta.lowest() will include the current bar. So, you can directly compare it with low.

    ll = ta.lowest(bars_back) //15-d-low
    is_lowest = (low == ll)
    
    plotshape(is_lowest)