Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

trading - 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)
question from:https://stackoverflow.com/questions/65910436/pine-script-question-highest-high-versus-highest-close

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...