如何在Pinescript中绘制从高点到低点的趋势线?

时间:2020-09-28 11:48:27

标签: pine-script

How to draw a trend line from day high to day low?

就像图像中一样,我创建了一条趋势线指示器,该指示器连接了当天和前一天的高点和低点(仅持续2天)。但问题是,最高点和最低点正好相反。如何解决? 谢谢。

      //@version=4
      study("HL", shorttitle="HL", overlay=true)

      dayHighHTF  = security(syminfo.tickerid, "D", high, lookahead=true)
      prev1HighHTF  = security(syminfo.tickerid, "D", high[1], lookahead=true)
      dayLowHTF  = security(syminfo.tickerid, "D", low, lookahead=true)
      prev1LowHTF  = security(syminfo.tickerid, "D", low[1], lookahead=true)

      if (barstate.islast)
          line.new(x1=bar_index[24], y1=dayLowHTF, x2=bar_index, y2=dayHighHTF)
          line.new(x1=bar_index[49], y1=prev1LowHTF, x2=bar_index[25], y2=prev1HighHTF)

0 个答案:

没有答案