【问题标题】:Pinescript: Plotting conditional arrow within tablePinescript:在表格内绘制条件箭头
【发布时间】:2022-10-17 19:20:12
【问题描述】:

我正在努力在表格中绘制一个向上或向下的箭头,具体取决于条件。

我尝试了这段代码,但我认为参数 plotshope 和 fillcell 都不合适。

请有人可以帮助我了解如何执行此操作。

f_fillCell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) =>
    _cellText = _title + '\n' + _value
    table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor)

// Draw table
var bgcolor = color.new(color.black, 0)
if drawTable
    if barstate.islastconfirmedhistory
        // Update table
        if tf1bull == true
        plotshape(divTable, 0, 1, (lbrTF1), tf1bull ? style=shape.arrowup, color=color.green : shape.arrowdown, color=color.red)```

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    您不能在本地范围内调用绘图函数。

    您可以简单地在文本字段中使用箭头。

    //@version=5
    indicator("My script",overlay=true)
    
    var testTable = table.new(position = position.top_right, columns = 1, rows = 1, bgcolor = color.yellow, border_width = 1)
    if barstate.islast
        table.cell(table_id = testTable, column = 0, row = 0, text = "????????")
    

    【讨论】:

    • 感谢您的答复。为延迟道歉 - 我很自豪地在发现 ascii 的奇迹后找到了我的方式。
    【解决方案2】:

    经过一番折腾,我最终发现我可以在文本字段中使用大量的 ascii 字符,从而解决了这个问题。

    如果它对其他人有用,我的最终脚本如下:

    if drawTable
        if barstate.islastconfirmedhistory and tf1bull == true and sigSlope1 == 0
            table.cell(divTable, 1, 0, ("TF" + lbrTF1 + " ᐱ"), text_color=color.red)
        else if barstate.islastconfirmedhistory and tf1bull == true and sigSlope1 == 1
            table.cell(divTable, 1, 0, ("TF" + lbrTF1 + " ᐱ"), text_color=color.green)
    
        else if barstate.islastconfirmedhistory and tf1bear == true and sigSlope1 == 1
            table.cell(divTable, 1, 0, ("TF" + lbrTF1 + " ᐯ"), text_color=color.green)
        else if barstate.islastconfirmedhistory and tf1bear == true and sigSlope1 == 0
            table.cell(divTable, 1, 0, ("TF" + lbrTF1 + " ᐯ"), text_color=color.red)
        ```
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多