'Pine-Script - Input actual time as Default
i´m trying to fill a Date input with a default value, the default value should be the actual date.
The original code:
end_time = input.time(defval=timestamp('01 Aug 2021 00:00 +0000'), title='End Time')
I would like to have the actual date as defval.
i tried several things, like timestamp(timenow) but i get always the same error-message:
An argument of 'series int' type was used but a 'const string' is expected
I understand that i bring a int to a string, but how can i convert the actual date/time to fit in the code above?
Thanx for your brains,
Solution 1:[1]
The input.*() function defval= argument requires a value known at the compilation time and could not be dynamic.
As a workaround, you can use the interactive feature (confirm= argument) to select the last bar on the chart with a mouse-click:
//@version=5
indicator("My script")
end_time = input.time(defval=timestamp('01 Aug 2021 00:00 +0000'), title='End Time', confirm = true)
bgcolor(time == end_time ? color.red : na)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | e2e4 |
