Adds a session setting to the script and returns it as text such as "0930-1600".
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
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 stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const string | required | Default session text, such as "0930-1600". |
| title | const string | na | Name shown in the Settings dialog, the legend and the Data Window. |
| options | tuple of const string values: [val1, val2, ...] | na | A list of allowed sessions. When given, the setting is a dropdown. |
| tooltip | const string | na | Text shown in a tooltip beside the input in the Settings dialog. |
| inline | const string | na | Entries sharing the same inline text sit on one row of the Settings dialog. |
| group | const string | na | Heading the input is listed under in the Settings dialog. |
| confirm | const bool | false | When true, the script asks for this value when it is first added to the chart. |
| display | const plot_display | display. | Where the value appears: a display.* constant or a combination of them. |
| active | input bool | true | When 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
//@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