Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

pine script - Not getting proper daily high and low on Historical bars

I am using the following code to calculate Daily High and LowdayHigh = security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_off) dayLow = security(syminfo.tickerid, 'D', low, lookahead=barmerge.lookahead_off)

I am using on the 15 mins chart. In the live market it shows me the correct update values on the 15 minutes as the chart progresses, but when I try checking the H/L every bar in the history(i.e before today) it shows be the Daily High and Low which formed end of day but not the actual H/L which happened on that 15 min bar.I tried using barmerge.lookahead_on too, but the results were same

How to solve this?

question from:https://stackoverflow.com/questions/65853437/not-getting-proper-daily-high-and-low-on-historical-bars

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

1 Answer

0 votes
by (71.8m points)

This solved the problem

// Keep track of current day's high.

var dayHigh = 0.0 dayHigh := change(dayofweek) ? high : max(high, dayHigh)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...