Sidechair

input.session()

Browse the reference

Adds a session setting to the script and returns it as text such as "0930-1600".

Try it in the editor

input.session returns a session string in the form HHMM-HHMM, optionally followed by days such as ":23456" for Monday to Friday. Start from defval, for example "0930-1600".

Pass the string as the second argument of the time function to test whether a bar falls inside the session: not na(time(timeframe.period, sess)).

Syntax

Pine Script
input.session(defval: const string, title: const string (optional), options: tuple of const string values: [val1, val2, ...] (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), confirm: const bool (optional), display: const plot_display (optional), active: input bool (optional)) -> input string

Arguments

NameTypeDefaultDescription
defvalconst stringrequiredDefault session text, such as "0930-1600".
titleconst stringnaName shown in the Settings dialog, the legend and the Data Window.
optionstuple of const string values: [val1, val2, ...]naA list of allowed sessions. When given, the setting is a dropdown.
tooltipconst stringnaText shown in a tooltip beside the input in the Settings dialog.
inlineconst stringnaEntries sharing the same inline text sit on one row of the Settings dialog.
groupconst stringnaHeading the input is listed under in the Settings dialog.
confirmconst boolfalseWhen true, the script asks for this value when it is first added to the chart.
displayconst plot_displaydisplay.allWhere the value appears: a display.* constant or a combination of them.
activeinput booltrueWhen false, the input is greyed out and cannot be edited.

Returns

input string: the session text.

Remarks

  • On Sidechair: the setting is a text field unless options is given.
  • On Sidechair: confirm, display and active are accepted and ignored.

Example

Pine ScriptShade a chosen sessionOpen in editor
//@version=6
indicator("Session shading", overlay = true)
sess = input.session("0930-1000", "Session")
inSession = not na(time(timeframe.period, sess))
bgcolor(inSession ? color.new(color.blue, 88) : na)

See also

Runs on Sidechair