Adds a date and time setting to the script and returns it as a timestamp in milliseconds since 1970.
input.time returns a Unix timestamp in milliseconds, starting at defval. Write the default with the timestamp function, for example timestamp("2024-01-15T09:30:00").
Compare it with the time variable to start or stop a calculation at a chosen date: time >= startTime.
Syntax
input.time(defval: const int, title: const string (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 intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const int | required | Default timestamp in milliseconds, usually made with the timestamp function. |
| title | const string | na | Name shown in the Settings dialog, the legend and the Data Window. |
| 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 int: the chosen timestamp, in milliseconds.
Remarks
- On Sidechair: the setting is a number box holding the millisecond value, not a calendar picker.
- On Sidechair: confirm, display and active are accepted and ignored.
Example
//@version=6
indicator("From date", overlay = true)
start = input.time(timestamp("2024-01-02T00:00:00"), "Start")
bgcolor(time >= start ? color.new(color.green, 92) : na)See also
Runs on Sidechair