Pinescript:获取战略年份。

发布于 2025-02-09 03:44:13 字数 259 浏览 0 评论 0原文

我想知道是否有可能在策略中的每一个贸易贸易中获得购买年份。

我尝试使用 strument.closedtrades.entry_time [num_trade] ,但我无法从这个Unix时间戳中获得这一年。

另一方面,我试图使用 年[straution.closedtrades.entry_bar_index [num_trade]] ,但由于许多已使用的栏,这会引起错误。

知道是否可以吗?

I would like to know if it is possible in pinescript to get the buy year for every trade in strategy.closedtrades?

I tried to use strategy.closedtrades.entry_time[num_trade] but I was not able to get the year out of this Unix timestamp.

On the other hand I have tried to use
year[strategy.closedtrades.entry_bar_index[num_trade]], but this raises an error because of to many used bars.

Any idea if this is possible?

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

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

发布评论

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

评论(1

微凉徒眸意 2025-02-16 03:44:13

您可以使用Year()函数来获取时间戳年度。例如:

year(strategy.closedtrades.entry_time(strategy.closedtrades - 1))

您可以通过封闭的交易进行循环,并做您想要的事情。例如:

for i = 0 to strategy.closedtrades - 1
    yearOfBuy = year(strategy.closedtrades.entry_time(i))
    if yearOfBuy == 2020
        do something 

You can use the year() function to get the year of a timestamp. For example:

year(strategy.closedtrades.entry_time(strategy.closedtrades - 1))

You can loop through the closed trades, and do the thing you want. For example:

for i = 0 to strategy.closedtrades - 1
    yearOfBuy = year(strategy.closedtrades.entry_time(i))
    if yearOfBuy == 2020
        do something 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文