如何在给定的时间范围内使条形计数从 1 开始?
How to make bar count start at 1 for a given timeframe?
有没有什么方法可以让给定时间范围内的第一个柱的柱数从 1 开始?如图所示,现在从图表上的第一个柱开始...
study(title="candle count" ,overlay=true)
i_startTime = input(defval = timestamp("01 Jan 2022 08:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("01 Feb 2022 15:30 +0000"), title = "End Time", type = input.time)
inDateRange = time >= i_startTime and time <= i_endTime
Count = inDateRange ? bar_index : na
//Count = bar_index + 1
label.new(time >= i_startTime and time <= i_endTime ? bar_index : na,high,tostring(Count),textcolor=color.blue,style=label.style_none)```
[![`enter image description here`][1]][1]
[1]: https://i.stack.imgur.com/BhCXH.png
只需使用您自己用 var 关键字声明的变量,这样就不会在每个柱线都重置。
var int Count = 0
if inDateRange
Count += 1
有没有什么方法可以让给定时间范围内的第一个柱的柱数从 1 开始?如图所示,现在从图表上的第一个柱开始...
study(title="candle count" ,overlay=true)
i_startTime = input(defval = timestamp("01 Jan 2022 08:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("01 Feb 2022 15:30 +0000"), title = "End Time", type = input.time)
inDateRange = time >= i_startTime and time <= i_endTime
Count = inDateRange ? bar_index : na
//Count = bar_index + 1
label.new(time >= i_startTime and time <= i_endTime ? bar_index : na,high,tostring(Count),textcolor=color.blue,style=label.style_none)```
[![`enter image description here`][1]][1]
[1]: https://i.stack.imgur.com/BhCXH.png
只需使用您自己用 var 关键字声明的变量,这样就不会在每个柱线都重置。
var int Count = 0
if inDateRange
Count += 1