如何在特定时间发送警报

编程入门 行业动态 更新时间:2024-10-25 09:34:30
本文介绍了如何在特定时间发送警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想写一个松树脚本,它会向我发送一份股票报告,说是枢轴点、RSI 等......每天早上 7 点和下午 3 点,当 mrkt 关闭时.我知道如何发出警报,这是触发是我不知道如何告诉它在早上 7 点和下午 3 点向我发送警报.关于如何实现这一点的任何想法?我查看时间戳或时间,但不知道如何使该条件发送警报.谢谢

I'd like to write a pine-script that will send me a report of the stock, says, it's pivot points, rsi, etc ... at 7am every morning and 3pm when mrkt close. I know how to do the alert, it's the trigger is I don't know how to tell it to send me the alert at 7am and 3pm. Any thought on how to accomplish this? I look into timestamp or time, but don't know how to make that condition to send the alert. Thanks

推荐答案

有多种方法可以做到,其中一种方法是从时间 x 到时间 y 创建一个会话并获取它的开始和结束.

There are multiple ways of doing it, one of them is to create a session from time x to time y and get the start and the end of it.

我为每个部分添加了评论以了解它是如何工作的.

I added comments for each section to see how it's working.

//@version=4 study("My Script", overlay = true) //Sessions session = input(title="Session", type=input.session, defval="0930-1555") //Check if it's new bars is_newbar2(sess) => t = time("D", sess) na(t[1]) and not na(t) or t[1] < t //Check if it's in session is_session(sess) => not na(time(timeframe.period, sess)) //Call the function Session = is_session(session) //Plot the background color to see the session bgcolor(Session ? color.new(color.aqua, 95) : na) //Start and end of the session start = Session and not Session[1] end = (not Session) and Session[1] //Plot the start and the end of the session plotshape(start, style=shape.labeldown, color = color.aqua, text = "Start", textcolor = color.black, size = size.small) plotshape(end, style=shape.labeldown, color = color.purple, text = "End", textcolor = color.black, size = size.small) //Alerts if start alert("text alert", alert.freq_once_per_bar) if end alert("text alert", alert.freq_once_per_bar_close)

写下会话的开始时间(如果它从早上 7 点开始,那么写在 07:00)和从会话的最后一根蜡烛开始的时间(如果您在 5m 图表中并且会话在下午 2 点到期)非常重要,写13:55,如果你在1H图写13:00...等等),那是因为在会话结束后,Tradingview会阻塞任何功能...因为市场关闭,所以我们需要获取会话的最后一个小节.

It's very important to write the starting of the session (if it start at 7am, then write exactly 07:00) and the time from the last candle of the session (if you are in 5m chart and the session expire at 2pm, write 13:55, if you are in 1H chart write 13:00...and so on), that's because after the end of the session, Tradingview will block any functions...since the market is closed, so we need to get the last bar of the session.

对于警报,您只需输入文本即可.

For the alerts, you just put your text and it's ready to go.

更多推荐

如何在特定时间发送警报

本文发布于:2023-11-27 05:23:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636770.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   时间   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!