timeframe.period的值(以秒计)是多少?
要检测秒分辨率,唯一可能的方法是使用timeframe.isseconds。
1分钟
if timeframe.period == "1"
发布于 2021-01-07 01:00:03
它是1秒的"S“,"5S",”15“或”30“。
您可以使用PineCoders的f_resInMinutes()
函数以浮点分钟格式返回TF。让事情变得更简单。
您可以使用以下方法运行一个简单的发现测试:
//@version=4
study("")
f_print(_text) => var _label = label.new(bar_index, na, _text, xloc.bar_index, yloc.price, color(na), label.style_none, color.gray, size.large, text.align_left), label.set_xy(_label, bar_index, highest(10)[1]), label.set_text(_label, _text)
f_print(timeframe.period)
// ————— Converts current chart timeframe into a float minutes value.
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
plot(f_resInMinutes())
Disclosure:这个答案中的链接指向一个PineCoders FAQ条目。
我是PineCoders社区的一员,我很可能写了FAQ条目。PineCoders是一个由TradingView支持的志愿松树编解码者团体,PineCoders的网站具有严格的教育性.TradingView和PineCoders都不能从向pinecoders.com发送流量中获得经济上的好处,而且该站点也不包含任何附属/推荐链接。
https://stackoverflow.com/questions/65604875
复制相似问题