Sidechair

log.warning()

Browse the reference

Writes a warning to the Pine Logs panel, for something unexpected that the script can carry on through.

Try it in the editor

log.warning(message) adds a line at the warning level, which the log panel shows apart from plain information. log.warning(formatString, arg0, arg1, ...) fills {0}, {1} and so on in the format string with the arguments.

Reach for it when a value is odd but not fatal, such as a missing input or a fallback that was applied. Use log.error when something went wrong, and runtime.error to stop the script.

Syntax

Pine Script
log.warning(message: series string) -> void
log.warning(formatString: series string, arg0, arg1, ...: series int/float/bool/string/array<int/float/bool/string>) -> void

Arguments

NameTypeDefaultDescription
messageseries stringrequiredThe text written to the log. It is one string, so build it with str.tostring or str.format.
formatStringseries stringrequiredText containing placeholders {0}, {1} and so on, filled with the arguments that follow.
arg0series int/float/bool/string/array<int/float/bool/string>requiredThe value for {0} in the format string.
arg1series int/float/bool/string/array<int/float/bool/string>requiredThe value for {1} in the format string.
...series int/float/bool/string/array<int/float/bool/string>requiredMore values for {2}, {3} and so on. Numbers, bools, strings and arrays of them are accepted.

Returns

Nothing.

Remarks

  • Logging does not change what the script computes or plots. Guard a call on every bar with a condition so the log stays readable.

Example

Pine ScriptWarn when volume is zeroOpen in editor
//@version=6
indicator("Volume warning")
plot(close, "Close", color.blue)
if volume == 0
    log.warning("No volume on bar {0}", bar_index)

See also

Runs on Sidechair