【问题标题】:How to send alert at a certain time如何在特定时间发送警报
【发布时间】:2021-05-27 04:59:56
【问题描述】:

我想写一个 pine 脚本,它会在每天早上 7 点和下午 3 点 mrkt 收盘时向我发送一份股票报告,说它是支点、rsi 等。我知道如何发出警报,这是触发因素,我不知道如何告诉它在早上 7 点和下午 3 点向我发送警报。 关于如何做到这一点的任何想法?我查看时间戳或时间,但不知道如何使该条件发送警报。 谢谢

【问题讨论】:

    标签: time alert pine-script


    【解决方案1】:

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

    我为每个部分添加了 cmets,看看它是如何工作的。

    //@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 将阻止任何功能...因为市场关闭, 所以我们需要获取会话的最后一个小节。

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

    【讨论】:

    • 就是这样!!非常感谢
    • 太好了,别忘了将答案标记为已接受
    • 我该怎么做?
    • 答案旁边应该有一个复选标记
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多