英文:
How to get daily high and low time in pine script?
问题
我正在尝试找出如何获取每日的最高价和最低价的时间,以便将其应用于较低时间框架的条件。
实际上,我想找出较低或较高水平中哪个在时间上更远或更接近。
在下面的代码中,期望的部分是空的,我不知道如何获取这些时间值。
如果您能的话,请为我提供指导。
//@version=5
indicator('HiLo', overlay=true, shorttitle='HiLo')
//获取最高价和最低价
isess = session.regular
t = ticker.new(syminfo.prefix, syminfo.ticker, session=isess)
todayHigh = request.security(t, 'D', high[0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
todayLow = request.security(t, 'D', low[0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//如何获取todayHigh和todayLow的时间?
//在此提前感谢
todayHighTime =
todayLowTime =
英文:
I'm trying to figure out how to get the daily high and low time so I can apply it to my conditions on the lower time frame.<br>
Actually, I want to find out which of the lower or upper levels is more distant or closer in time.<br>
In the code below, the desired section is empty and I don't know how to get those time values.
Please guide me if you can.
//@version=5
indicator('HiLo', overlay=true, shorttitle='HiLo')
//Get High&Low Price
isess = session.regular
t = ticker.new(syminfo.prefix, syminfo.ticker, session=isess)
todayHigh = request.security(t, 'D', high[0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
todayLow = request.security(t, 'D', low[0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//How To Get todayHigh and todayLow Time?
//Thank you in advance
todayHighTime =
todayLowTime =
////////////
答案1
得分: 1
跟踪每日最高价和最低价。对于这一点,您不需要使用 security()
函数。
以下是 high
价格的示例。
//@version=5
indicator("My script", overlay=true)
var float high_price = na
var int high_time = na
is_new_day = ta.change(time("D"))
bgcolor(is_new_day ? color.new(color.blue, 85) : na)
if (is_new_day)
high_price := high
high_time := time
else
if (high > high_price)
high_price := high
high_time := time
plot(high_price)
请注意,time
返回的是UNIX格式的时间。
英文:
Track the daily high and low yourself. You don't need a security()
function for this.
Here is an example for the high
price.
//@version=5
indicator("My script", overlay=true)
var float high_price = na
var int high_time = na
is_new_day = ta.change(time("D"))
bgcolor(is_new_day ? color.new(color.blue, 85) : na)
if (is_new_day)
high_price := high
high_time := time
else
if (high > high_price)
high_price := high
high_time := time
plot(high_price)
Please note that time
returns time in UNIX format.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论