如何找到上周一的小节数量?交易观点 [英] How to find the number of bars from the last Monday ? tradingview
本文介绍了如何找到上周一的小节数量?交易观点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请告诉我如何查找上一个日期的小节数.
Please tell me how to find the number of bars from a previous date.
即今天是2021年3月12日(星期五),即时消息显示在1分钟时间表上
i.e today is Friday 12-Mar-2021 and Im on the chart of 1 minute timeframe
如何知道2021年8月8日星期一的酒吧数量?
How to know the number of bars from Monday 8-Mar-2021 00:00:00 ?
从2021年1月1日星期一开始00:00:00
And from Monday 1-Mar-2021 00:00:00
谢谢
推荐答案
//@version=4
study("Number of bars from date", "Bars", true)
var int i_date_start = input(timestamp("2021-03-08"), "Start date", input.time)
var int bar_index_start = na
var int bar_count = na
if na(bar_index_start) and time >= i_date_start
bar_index_start := bar_index
if barstate.islast
bar_count := bar_index - bar_index_start
label.new(bar_index, high, "Bar count = " + tostring(bar_count))
plot(na)