Search code examples
pine-scriptpine-script-v5

Total Shares Outstanding not working any longer in v5 pine script


I have just tried this

//@version=5
indicator("MarketCap", overlay=true, timeframe="", timeframe_gaps=true)
Outstanding = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
MarketCap = Outstanding*close
plotchar(MarketCap, "MarketCap", "", location = location.top)

for AAPL but its returning 0.

Anyone know what's wrong here?


Solution

  • You don't have 'TSO' identified, you need to switch your plotchar series to 'Outstanding'. Also it is request.financial() in version 5. Working code below

    //@version=5
    indicator("MarketCap", overlay=true, timeframe="", timeframe_gaps=true)
    Outstanding = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
    MarketCap = Outstanding*close
    plotchar(Outstanding, "TSO", "", location = location.top)
    

    Here it is plotted with MarketCap per your comment request. Both seem to work fine. enter image description here