简体   繁体   中英

Pine script question highest high versus highest close

I know that the script below will plot the highest high and lowest low, but how do I do the exact same kind of plot but using the highest bar/candle and lowest bar/candle?

If I just plot the close it will plot the bottom of a descending bar, and the top of an ascending. I want the top of either ascending or descending, and the bottom of either on two separate lines. Help is greatly appreciated. I am trying to figure this stuff out but I am struggling with this.

I really wish it had a var = highest bar (high, length) function, that would make life simple

//@version=4

study("My Script",overlay=true)

lookbackres= input(3,title="Res Lookback")

lookbacksup= input(3,title="Sup Lookback")

res=highest(high,lookbackres)

sup=lowest(low,lookbacksup)

plot(series=res, color=color.green, linewidth=2)

plot(series=sup, color=color.red, linewidth=2)

you could use the min/max function to achieve that.

so in the end, your final code could look like this:

//@version=4
study("My Script",overlay=true)
lookbackres= input(3,title="Res Lookback")
lookbacksup= input(3,title="Sup Lookback")
res=highest(max(open,close),lookbackres)
sup=lowest(min(open,close),lookbacksup)
plot(series=res, color=color.green, linewidth=2)
plot(series=sup, color=color.red, linewidth=2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM