Language
Time and sessions
The OTC feed trades around the clock on UTC. Reading bar time, filtering by hour, and what session variables mean here.
The clock this feed runs on#
OTC pairs on Tradequix trade 24 hours a day, 7 days a week, and bars sit on a plain UTC grid. For a script that means:
syminfo.timezoneis"Etc/UTC"andsyminfo.sessionis"24x7".- There are no weekend gaps and no market open or close, so
session.ismarketis always true and pre- and post-market are empty. - Symbols look like
EURUSD_otc. For six-letter pairs,syminfo.basecurrencyandsyminfo.currencyare filled from the name (EUR,USD).
Reading time#
time is the bar's open time in milliseconds. The calendar functions take a time and, optionally, a timezone:
| Function | Gives |
|---|---|
year(time), month(time), dayofmonth(time) | The date |
hour(time), minute(time), second(time) | The time of day |
dayofweek(time) | 1 (Sunday) to 7 (Saturday) |
timestamp(...) | A time from parts |
They default to UTC here. Pass a timezone to shift: hour(time, "Asia/Dhaka").
Trading hours of your own#
Even on a round-the-clock feed you may only want to act at certain hours. Filter by hour:
//@version=6indicator("London hours", overlay = true)h = hour(time, "UTC")inLondon = h >= 7 and h < 16bgcolor(inLondon ? color.new(#8b7cff, 90) : na)Formatting a time#
str.format_time(time, "yyyy-MM-dd HH:mm", "UTC") turns a time into text for a label or a table.