【问题标题】:How do I plot lines in the future in pine script?将来如何在 pine 脚本中绘制线条?
【发布时间】:2021-11-09 21:40:39
【问题描述】:

我一直在尝试为我编写的脚本绘制止盈和止损线,但我在未来绘制线时遇到了困难。

我尝试过使用 plot 和 line.new 函数但没有成功。

An example of what I would like to see

【问题讨论】:

标签: pine-script trading


【解决方案1】:

您可以计算要在图表上绘制的值,然后设置偏移量。像这样的,

plot(close, offset = 1, color = color.black, linewidth=2)

这里的偏移量将是未来的数字条。即 1 是将来计算的 bar。

【讨论】:

    【解决方案2】:

    我写的东西完全符合你的要求。我将 Daily Pivot 线绘制在条形的右侧,因此它们不会妨碍您。诀窍是使用趋势线而不是“绘图”线,并让趋势线偏移一定的时间,而不是使用“偏移”功能。

    你可以看到我使用 labeldt 计算一个柱的时间值,然后使用 (time + (labeldt * 20)) 定义 x1 和 x2 选项,这意味着趋势线从当前柱开始并绘制 20 个柱进入未来。 y1 和 y2 选项定义了绘制的价格水平。

    祝你好运

    /////////////////////
    // F L O O R   P I V O T S
    // 
    /////////////////////
    
    labeldt = time - time[1]
    
    /////////////////
    //LINE PRICE CALCULATIONS
    /////////////////////////
    PPFunc() =>
        xHighPP = high[1]
        xLowPP = low[1]
        xClosePP = close[1]
        [xHighPP, xLowPP, xClosePP]
    
    [xHigh, xLow, xClose] = security(syminfo.tickerid, 'D', PPFunc())
    
    //xHigh  = security(tickerid,1440, high[1])
    //xLow   = security(tickerid,1440, low[1])
    //xClose = security(tickerid,1440, close[1])
    
    vPP = (xHigh+xLow+xClose) / 3
    
    /////////////////////////
    
    //LINE PLOT
    
    PlothlineDayPivotPoint = line.new(x1=time, y1=vPP, x2=time + (labeldt * 20), y2=vPP, extend=extend.none, color= #0000ff, xloc=xloc.bar_time)
    
    //LINE STYLE
    
    line.set_width(PlothlineDayPivotPoint, 1)
    
    //LINE DELETER
    
    line.delete(PlothlineDayPivotPoint[1])
    
    /////////////////////
    

    出于您的目的,您可以忽略“线价格计算”部分 - 这只是我在计算价格水平。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 2023-02-10
      • 2023-02-17
      • 1970-01-01
      相关资源
      最近更新 更多