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:

plot(variable_name)

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 label.new() function:

label.new(bar_index, high, text=syminfo.ticker)

You can also use label.new() to display the value of a numeric variable by first converting it to a string using the tostring() function:

label.new(bar_index, high, text=tostring(high))

The label.new() function will only display the last ~50 values of the variable.

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