How to get a value of the variable for debugging purposes

To display the value of a numeric variable, you can plot it using the plot() function:


This allows you to inspect the variable's value on each chart bar and follow its progression if it changes.
If you want to display the value of a string variable, use the function:, high, text=syminfo.ticker)

You can also use to display the value of a numeric variable by first converting it to a string using the str.tostring() function:, high, text=str.tostring(high))

The function will only display the last ~50 values of the variable by default.

A more detailed tutorial on debugging in Pine can be found in this article in Pine User Manual.