Time 如何在特定时间发送警报

Time 如何在特定时间发送警报,time,alert,pine-script,Time,Alert,Pine Script,我想写一个pine脚本,它会给我一份股票报告,比如说,它是pivot points,rsi,等等。。。每天早上7点和下午3点mrkt关闭时。我知道如何发出警报,触发的原因是我不知道如何告诉它在早上7点和下午3点向我发送警报。 有没有想过如何做到这一点?我查看了时间戳或时间,但不知道如何设置发送警报的条件。 感谢有多种方法,其中之一是从时间x到时间y创建一个会话,并获取会话的开始和结束 我为每个部分添加了注释,以查看其工作情况 //@version=4 study("My Script&

我想写一个pine脚本,它会给我一份股票报告,比如说,它是pivot points,rsi,等等。。。每天早上7点和下午3点mrkt关闭时。我知道如何发出警报,触发的原因是我不知道如何告诉它在早上7点和下午3点向我发送警报。 有没有想过如何做到这一点?我查看了时间戳或时间,但不知道如何设置发送警报的条件。
感谢有多种方法,其中之一是从时间x到时间y创建一个会话,并获取会话的开始和结束

我为每个部分添加了注释,以查看其工作情况

//@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)
/@version=4
研究(“我的脚本”,overlay=true)
//会议
会话=输入(title=“session”,type=input.session,deffal=“0930-1555”)
//看看是不是新酒吧
is_newbar2(sess)=>
t=时间(“D”,sess)
na(t[1]),而不是na(t)或t[1]
非na(时间(timeframe.period,sess))
//调用函数
Session=is_Session(Session)
//绘制背景色以查看会话
bgcolor(会话?color.new(color.aqua,95):na)
//会话的开始和结束
开始=会话,而不是会话[1]
结束=(非会话)和会话[1]
//绘制会话的开始和结束
plotshape(开始,style=shape.labeldown,color=color.aqua,text=“开始”,textcolor=color.black,size=size.small)
plotshape(end,style=shape.labeldown,color=color.purple,text=“end”,textcolor=color.black,size=size.small)
//警报
如果开始
警报(“文本警报”,警报.频率每栏一次)
如果结束
警报(“文本警报”,警报.频率一次\u每\u条\u关闭)
写下会话的开始时间(如果在早上7点开始,那么写下确切的07:00)和会话最后一支蜡烛的时间(如果你在5m图表中,会话在下午2点结束,写下13:55,如果你在1H图表中,写下13:00…等等),这非常重要,因为会话结束后,Tradingview将阻止任何功能…因为市场已关闭,所以我们需要获得该时段的最后一条

对于警报,您只需将文本放入即可


就这样!!谢谢,太好了,别忘了将答案标记为已接受。我该怎么做?答案旁边应该有一个复选标记