Cause
+ can add two numbers or join two strings, but not mix them. "Close: " + close joins a string with a float.
Broken code
TradingView reports the error on line 4.
//@version=6
indicator("Close label", overlay = true)
if barstate.islast
label.new(bar_index, high, "Close: " + close)Fixed code
The same script, corrected for Pine Script v6. Paste it into the Pine Editor and save.
//@version=6
indicator("Close label", overlay = true)
if barstate.islast
label.new(bar_index, high, "Close: " + str.tostring(close, format.mintick))Why it works
str.tostring() converts the number to a string first, so both sides of + are strings and Pine joins them. format.mintick rounds to the symbol's tick size; a pattern such as "#.##" keeps two decimals, and format.percent and format.volume are also available.
Alert messages
The same applies to alert() messages built at runtime:
rsi = ta.rsi(close, 14)
if ta.crossover(rsi, 70)
alert("RSI crossed 70: " + str.tostring(rsi, "#.0"), alert.freq_once_per_bar_close)
alertcondition() messages must be fixed strings; use placeholders such as {{ticker}} and {{close}} there instead of concatenation.
Questions
How do I concatenate a string and a number in Pine Script?
Convert the number first: "Close: " + str.tostring(close). Add a format as the second argument, such as format.mintick or "#.##", to control the decimals.
Why does the message say a "series float" is expected?
Because one side of + is a number, the compiler tries numeric addition and then reports the string as the argument that doesn't fit. The fix is the same either way: make both sides strings.
The scripts on this page are minimal examples written to show the error and its fix, not trading systems. Trading involves substantial risk of loss and is not suitable for every investor. Edgoro is a software tool, not a broker or financial adviser: nothing it produces is investment advice, and past or backtested performance does not guarantee future results.