【问题标题】:Trading View Pine Script : How to Draw a Simple Line Using line.new function from market open to market close?Trading View Pine Script : 如何使用 line.new 功能从开市到收市画一条简单的线?
【发布时间】:2022-01-09 05:28:12
【问题描述】:

我想使用 line.new 函数画一条线,如下所示:

时间轴: 自动从开市开始到收市结束。 适用于所有市场、国际和本地市场以及所有资产类别。不限特定时间。

价格轴: 每日支点

非常感谢您的帮助。 请

//@version=5
indicator('Pivot', overlay=true, shorttitle='Pivot', precision=1, max_bars_back=4500)

//******************LOGIC**************************
//cenral pivot range
pivot = (high + low + close) / 3  //Central Povit


//******************Line**************************
line.new(x1 = time('D', "open"), y1 = pivot ,         x2 = time('D', "close"), y2 = pivot ,               xloc=xloc.bar_time, style=line.style_solid, width  = 2, color  = color.new(#0000FF, 0)) //


【问题讨论】:

    标签: pine-script trading pine-script-v4 pinescript-v5


    【解决方案1】:

    您可以将这条线向右延伸。
    此外,您的枢轴计算有一个 Pine 内置 hlc3

    //@version=5
    indicator('Pivot', overlay=true, shorttitle='Pivot')
    
    // define line, extend to the right
    var line    pivotLine = line.new(na, na, na, na, xloc=xloc.bar_time, style=line.style_solid, width=2, color=color.new(#0000FF, 0), extend=extend.right)
    
    pivot = request.security(syminfo.tickerid, 'D', hlc3[1])
    
    // new day?
    if ta.change(dayofmonth)
        // move line
        line.set_xy1(pivotLine, time,   pivot)
        line.set_xy2(pivotLine, time+1, pivot)
    

    【讨论】:

    • 此代码需要调整,但可行。我明白了。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    相关资源
    最近更新 更多