Pine script 在pine脚本中的所需固定时间执行代码

Pine script 在pine脚本中的所需固定时间执行代码,pine-script,Pine Script,我在pine开发了一个信号发生器来处理索引。我被困在一个我希望在每天下午3点/1500小时5分钟结束时执行退出代码的地方。但是,我无法读取当前时间并执行代码。 这就是我尝试过的 时间检查=小时==1500 我将请求对此问题的支持。PineCoders常见问题解答的时间、日期和会话部分帮助我做了类似的事情 如果您使用此内容在PineScript中创建一个新指示器,它可能会为您提供一些有用的起点: //@version=4 study("Time Example", overla

我在pine开发了一个信号发生器来处理索引。我被困在一个我希望在每天下午3点/1500小时5分钟结束时执行退出代码的地方。但是,我无法读取当前时间并执行代码。 这就是我尝试过的 时间检查=小时==1500
我将请求对此问题的支持。

PineCoders常见问题解答的时间、日期和会话部分帮助我做了类似的事情

如果您使用此内容在PineScript中创建一个新指示器,它可能会为您提供一些有用的起点:

//@version=4
study("Time Example", overlay=false)

// You can plot your value only at a certain time.
// Here we plot 9 if it is the right time, and 0 if not.
// Replace 9 with a call to whatever function you want.

plot(not na(time("5", "1500-1504")) ? 9 : 0, color=color.blue)

// Or, you can set a value to na at first:
var int red_val = na

// And then change it only when the right time comes,
// when you are finally able to calculate it.
// Here we check if this bar's start time, if converted
// to 5-minute resolution, would start at 1500.
// Note: this uses the time zone of the exchange that
// the current symbol is traded on, not your local time.

if not na(time("5", "1500-1504"))
    // You would put own your calculation here.
    // This dayofmonth() call is just an example.
    red_val := dayofmonth(timenow)

// Then, for example, you can plot the final result
// of your calculation later on in your code:
plot(red_val, color=color.red)
在这两个例子中,
而不是na(时间(“5”,“1500-1504”)
对于您的情况非常重要。如果您查看上面链接的常见问题,还有其他(可能更好)的方法


上的PineScript参考资料也很有用,但它确实是FAQ中对我帮助最大的示例。

非常感谢……它帮助我立即解决了问题