Skip to content
Algo Trade Analytics Docs

input.enum() - Pine Script Function

Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users. This function adds a dropdown with options based on the enum fields passed to its defval and options parameters.

input.enum(defval, title, options, tooltip, inline, group, confirm, display, active) → input enum
NameTypeDescription
defvalconst enumDetermines the default value of the input
whichusers can change in the script’s “Settings/Inputs” tab. When the options parameter has a specified tuple of enum fields
thetuple must include the defval.

Value of input variable.

  • All fields included in the defval and options arguments must belong to the same enum.
//@version=6
indicator("Session highlight", overlay = true)//@enum Contains fields with popular timezones as titles.//@field exch Has an empty string as the title to represent the chart timezone.enum tz utc = "UTC" exch = "" ny = "America/New_York" chi = "America/Chicago" lon = "Europe/London" tok = "Asia/Tokyo"//@variable The session string.selectedSession = input.session("1200-1500", "Session")//@variable The selected timezone. The input's dropdown contains the fields in the `tz` enum.selectedTimezone = input.enum(tz.utc, "Session Timezone")//@variable Is `true`
if the current bar's time is in the specified session.bool inSession = false
if not
na(time("", selectedSession, str.tostring(selectedTimezone)))
inSession := true// Highlight the background when `inSession` is `true`.
bgcolor(inSession ? color.new(color.green, 90) : na, title = "Active session highlight")