Search code examples
pine-script-v5tradingview-apialgorithmic-trading

How to add prefix before value in the status line of chart(PINE script)


can't add prefix here

below is my code

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Bao1984

//@version=5
indicator("ATR in Percentage", "D", format=format.percent)

lengthofAtr = input.int(5, "ATR length", minval=2, group = "Length setting", inline = "01")
lengthofWMA = input.int(10, "WMA optimized by ATR length", minval=2, group = "Length setting", inline = "02")
noholiday   = input.bool(true, "Using holiday periods", group = "user define", inline = "01")

atrInPercentage = ta.atr(lengthofAtr)/(hlcc4*0.01)
atrweightedWMA = (ta.wma(ta.atr(lengthofAtr), lengthofWMA))/(ohlc4*0.01)


plot(atrInPercentage, title = "ATR in Percentage" + str.tostring(atrInPercentage), color=color.teal, linewidth=1, trackprice=true)
plot(atrweightedWMA, title = "ATR weighted WMA", color=color.gray, linewidth=1 )

I want to see these two words display on status line of chart


Solution

  • you can only see plot series in status.
    Try a table, below the status

    enter image description here

    f_printTable(_text) =>
        var table _printTable = table.new(position.top_left, 1, 1, force_overlay = true)
        table.cell(_printTable, 0, 0, _text, bgcolor = na, text_color = color.new(color.gray, 0))
    
    t_txt        = "\nATR in Percentage: " + str.tostring(atrInPercentage,format.percent) +
                   "\nATR weighted WMA: "  + str.tostring(atrweightedWMA,format.percent)
    
    f_printTable(t_txt)