简体   繁体   中英

How to get the closing price of the highest/lowest candle?

I have some coding background and usually I'd be able to solve this but I looked through the forums and Google and found no solution to this. Basically, I want the output from highestbars() or lowestbars() and put it in close[]. There is no quick solution for this because highestbars()/lowestbars() outputs datatype Series[integer] while 'close' takes in integer.

I've tried using a for loop to go through the same amount of candlesticks and check for highest/lowest prices but it doesn't work. I tried to just output highest and lowest to compare it with highest() and lowest() but it's not even close.

Any help would be appreciated since I've been stuck on this.

//@version=4
study("Highest and Lowest Zones", overlay=true)

float high_close = close[12]
float last_close_high = high_close
int high_bar = highestbars(64)[12]

high1 = highest(64)[12]
low1 = lowest(64)[12]

for i = 0 to 64
    closeHigh = (high[i+13] > high[i+12])
    high_close := closeHigh ? close[i]: last_close_high
    last_close_high := high_close

p1 = plot(high1, title="High", color=color.red)
p2 = plot(high_close, title="Low", color=color.red)
fill(p1, p2)

float low_close = close[12]
float last_close_low = low_close

for i = 0 to 64
    closeLow = (low[i+13] > low[i+12])
    low_close := closeLow ? close[i+13]: last_close_low
    last_close_low := low_close

p3 = plot(low1, title="High", color=color.green)
p4 = plot(low_close, title="Low", color=color.green)
fill(p3, p4)

这对我有用:

plot(close[0-highestbars(10)])

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