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.3k 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 Reply

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)


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

...