如何指定按时间而不是bar的偏移? V5

发布于 2025-01-26 09:46:52 字数 333 浏览 3 评论 0原文

我的某些规则(检测某些事情)在市场开放后一个小时发出错误警报(或者只是不够定义,而不是足够好,哈哈)。由于我可以找到营业时间的时刻,因此我可以相对地解决它的棒,这有点酷。有没有办法将其指定为时间偏移以使其不依赖(子时)时间表?

例如,在我的代码中,Marketopen规则是true如果当前市场打开的时刻仍在当前栏中(因此它解决了Marketsopen <的标准< /代码>在任何时间范围内)。在1小时的时间范围内,这将很简单:not(Marketopen)将排除第一个小时,但也应该在次小时时间内工作。

Some of my rules (to detect something) gives false alarms for an hour after Market Open (or simply just not defined well enough anyways, ha-ha). Since I can locate the moment of Market Open, I can address bars relatively to it which is kinda cool. Is there a way to specify offset by time to make it undependent to (sub-hour) timeframe?

For example in my code, MarketOpen rule is true if the current the moment of Market Open is still in the current bar (so it addresses the bar of MarketOpen in any timeframe). In 1H timeframe, it would be simple: not(MarketOpen) would exclude the first hour, but it should work in sub-hour timeframes, too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2025-02-02 09:46:52

如果您只想在特定的时间内进行交易,则可以使用session

session = input.session("1100-2000")
inSession = not na(time(timeframe.period, session))

long = inSession and yourCondition

无论如何,如果要在市场开放后1小时获得1小时的时间,则可以使用此信息:

newDay = ta.change(time("D"))
var float oneHourAfterMarketOpen = na

if newDay
    oneHourAfterMarketOpen := time + (60 * 60 * 1000)

canTrade = time > oneHourAfterMarketOpen

bgcolor(canTrade?color.green:color.red)

If you want to trade only in specific hours, you can use a session:

session = input.session("1100-2000")
inSession = not na(time(timeframe.period, session))

long = inSession and yourCondition

In any case, if you want to get the time of 1 hour after the market is open, you can use this:

newDay = ta.change(time("D"))
var float oneHourAfterMarketOpen = na

if newDay
    oneHourAfterMarketOpen := time + (60 * 60 * 1000)

canTrade = time > oneHourAfterMarketOpen

bgcolor(canTrade?color.green:color.red)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文