Tradingview Alert to Discord Webhooks时区转换

huangapple go评论43阅读模式
英文:

Tradingview Alert to Discord Webhooks timezone conversion

问题

我有这个在TradingView上的脚本警报:{"content": "10分钟RSI < 50 {{ticker}} 空头 时间={{timenow}}"}

而我在Discord上收到了这个警报:10分钟RSI < 50 EURUSD 空头 时间=2023-04-10T16:10:03Z

TradingView上的{timenow}默认是UTC时间。如何将时间=2023-04-10T16:10:03Z更改为EST时间,即时间=2023-04-10T12:10:03Z?非常感谢。

英文:

I have this alert with script {"content": "10 min RSI < 50 {{ticker}} SHORT Time ={{timenow}}"} on Trading view.

And I got the discord bot with the alert "10 mins RSI < 50 EURUSD SHORT Time =2023-04-10T16:10:03Z"

The default time for {timenow} on Tradingview is UTC time. How do I change Time =2023-04-10T16:10:03Z to EST time so that Time =2023-04-10T12:10:03Z? Many thanks.

答案1

得分: 1

在警报创建对话框中,您将无法更改时区,但您可以将隐藏的绘图添加到您的脚本中,并在警报创建对话框中以所需格式调用它们,例如:

plot(year(timenow, "America/New_York"), "currYear", display=display.none)
plot(month(timenow, "America/New_York"), "currMonth", display=display.none)
plot(dayofmonth(timenow, "America/New_York"), "currDay", display=display.none)
plot(hour(timenow, "America/New_York"), "currHour", display=display.none)
plot(minute(timenow, "America/New_York"), "currMinute", display=display.none)
plot(second(timenow, "America/New_York"), "currSecond", display=display.none)

并在创建警报时使用以下构造:

Time = {{plot("currYear")}}-{{plot("currMonth")}}-{{plot("currDay")}}T{{plot("currHour")}}:{{plot("currMinute")}}:{{plot("currSecond")}}

或者,更优化的方法是使用alert()函数,并将格式化的日期作为消息传递给它,例如:

alert(str.tostring(syminfo.tickerid) + " any your text " + str.format_time(timenow, "yyyy-MM-dd HH:mm:ssZ", "America/New_York"))

注意:alert()函数必须根据警报条件在代码中调用。

英文:

You won't be able to change the timezone in the alert creation dialog, but you can add hidden plots to your script and call them in the required format in the alert creation dialog, for example:

plot(year(timenow, "America/New_York"), "currYear", display=display.none)
plot(month(timenow, "America/New_York"), "currMonth", display=display.none)
plot(dayofmonth(timenow, "America/New_York"), "currDay", display=display.none)
plot(hour(timenow, "America/New_York"), "currHour", display=display.none)
plot(minute(timenow, "America/New_York"), "currMinute", display=display.none)
plot(second(timenow, "America/New_York"), "currSecond", display=display.none)

And use this construction when creating an alert

Time = {{plot("currYear")}}-{{plot("currMonth")}}-{{plot("currDay")}}T{{plot("currHour")}}:{{plot("currMinute")}}:{{plot("currSecond")}}

Or a more optimal method is to use the alert() function and pass a formatted date as a message to it in a string, example:

alert(str.tostring(syminfo.tickerid) + " any your text " + str.format_time(timenow, "yyyy-MM-dd HH:mm:ssZ", "America/New_York"))

Note: the alert() function must be called in the code according to the alert condition

huangapple
  • 本文由 发表于 2023年4月11日 00:29:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75978848.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定