【问题标题】:Pine Script strategy to trigger once per day?Pine Script 策略每天触发一次?
【发布时间】:2022-12-03 08:18:55
【问题描述】:

需要帮助编码Pine Script v5 攻略 每天触发一次
想使用“bar_index == 0”,但不知道如何建立 bar 索引在交易日开始时重新开始的时间。请帮忙!

【问题讨论】:

    标签: pine-script pinescript-v5 tradingview-api


    【解决方案1】:

    解决方案:https://www.tradingview.com/pine-script-reference/v5/#fun_timeframe{dot}change

    下面测试是否是新的一天

    if timeframe.change("D")
        ...
    

    【讨论】:

      【解决方案2】:

      我确定有更好的方法,但这对我有用:

      var traded_today = false
      
      //use whatever hours:days for first candle of time series chart
      //using 15min here, but can be done using an input()
      first_candle = time(timeframe.period, "9:30-9:15:12345"
      
      if (first_candle)
          traded_today := false
          
      condition = your_condition and not traded_today
      
      if (condition)
          traded_today := true 
      

      【讨论】:

        猜你喜欢
        • 2023-02-06
        • 2020-01-28
        • 1970-01-01
        • 1970-01-01
        • 2022-01-19
        • 1970-01-01
        • 2020-08-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多