Pine Script秒分辨率时间帧.period



timeframe.period的值是多少(以秒为单位(?

我检测秒分辨率的唯一可能方法是使用timeframe.isseconds

1分钟是

if timeframe.period == "1"

它是"S〃;持续1秒;5S"15S";或";30S";。

您可以使用PineCooders的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())

披露:此答案中的链接指向PineCooders常见问题条目
我是PineCooders社区的成员,我很可能写了那个常见问题条目。PineCoders是一个TradingView支持的PineCoder志愿者团体,PineCodeers的网站是严格的教育性网站。TradingView和PineCooders都没有从向pineCooders.com发送流量中获得经济利益,而且该网站不包含附属/推荐链接。

最新更新