Skip to content

Commit a803634

Browse files
authored
Update README.md
1 parent 013e6e9 commit a803634

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

faq_and_code/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,17 @@ f_nthDayofweekInMonth(_nth, _dayNo) =>
15681568
plotchar(f_nthDayofweekInMonth(i_nth, i_dayNo), "Day", "", location.top, size = size.tiny)
15691569
```
15701570

1571+
### How can I implement a countdown timer?
1572+
This code will work at intraday timeframes and at 1D. It would require more discerning logic for it to work on timeframes higher than that:
1573+
1574+
```js
1575+
//@version=4
1576+
study("Countdown", "", true)
1577+
int timeLeftInBar = (timeframe.isdaily and timeframe.multiplier == 1) or timeframe.isintraday ? (time_close - time) - (timenow - time) : 0
1578+
string countDown = str.format("{0,time,HH:mm:ss}", timeLeftInBar)
1579+
f_print(_text) => var table _t = table.new(position.middle_right, 1, 1), table.cell(_t, 0, 0, _text, bgcolor = color.yellow)
1580+
f_print(countDown)
1581+
```
15711582

15721583
**[Back to top](#table-of-contents)**
15731584

0 commit comments

Comments
 (0)