Trading sessions
A trading session defines the hours in a week when a symbol is actively traded on an exchange. A session is passed to the library in the session
field of the LibrarySymbolInfo
object. Session time should be in the exchange time zone.
Note that the last (rightmost) time of any session is non-inclusive. For example, if you specify a 0930-1630
session and select
the one‑hour resolution, the following bars are displayed on the chart: [09:30, 10:30, 11:30, 12:30, 13:30, 14:30, 15:30]
. The period of the last bar starts at 15:30 and ends at 16:30 that coincides with the end of the trading session.
The session
value affects how the library arranges data on the chart. Make sure you specify this property correctly to avoid potential issues, such as shifted bars.
Session formats
A trading session is defined by a string. This format allows you to describe a variety of sessions.
You can use the Session Parser to check your session string.
24/7 sessions
A session that runs 24 hours a day, 7 days a week, including Saturday and Sunday. It starts at 00:00 and ends at 00:00 the following day.
24x7
Intraday sessions
A session within a day. For example:
0930-1600
starts at 09:30 and ends at 16:00 from Monday to Friday.0000-0000
starts at 00:00 and ends at 00:00 the following day from Monday to Friday.
Overnight sessions
A session may last several days. For example:
1600-0930
starts at 16:00 on the previous day and ends at 09:30 on the current day.1700-1700
starts at 17:00 on the previous day and ends at 17:00 on the current day.
In Forex trading, sessions typically cover a full 24-hour period, five days a week, and use the time zone "Etc/UTC".
For example, you can configure a Forex session as 2200-2200
.
A session might start before the trading day. For example, the trading day is Monday, but the session starts on Sunday. You can specify a session that starts the day before the trading one using the F
character, for example, 1600F-0930
. If you want the session to start several days before the trading day, use Fn
, where n
is the number of days, for example, 1600F2-0930
. Note that the number of days cannot be more than 6.
1600F-0930
starts at 16:00 on the previous day and ends at 09:30 on the current day. For example, a Wednesday session starts at 16:00 and ends at 09:30 on Thursday.1900F-2350F
starts at 19:00 on the previous day and ends at 23:50 on the previous day. For example, a Monday session starts at 19:00 on Sunday and ends at 23:50 on Sunday.1900F3-1900
starts at 19:00 three days ago and ends at 19:00 on the current day. For example, a Friday session starts at 19:00 on Tuesday and ends at 19:00 on Friday.1900F3-2350F3
starts at 19:00 three days ago and ends at 23:50 three days ago. For example, a Friday session starts at 19:00 on Tuesday and ends at 23:50 on Tuesday.
Multiple sessions
There may be several sessions in one trading day. In this case, you should specify all sessions, separated by commas. For example, 0930-1400,1430-1700
. The first session starts at 09:30 and ends at 14:00. The second session starts at 14:30 and ends at 17:00.
Different sessions for different days
By default, sessions take place from Monday to Friday. There are no sessions on Saturday and Sunday. You can specify a session for a certain day by adding :n
, where n
is a day number. Day numbers are 1
for Sunday and 7
for Saturday (2
— Monday, 3
— Tuesday, etc.). Therefore, you can specify a Saturday/Sunday session. A session can relate to multiple days. For example, 0900-1400:23
means that the session starts at 09:00 and ends at 14:00 on Mondays and Tuesdays.
0900-1400:2|0900-1630
on Mondays the session starts at 09:00 and ends at 14:00. On all other days the session starts at 09:00 and ends at 16:30.2200-2200:3456|1700F-2200:2
a Monday session starts at 17:00 on Sunday and ends at 22:00 on Monday. On all other days the session starts at 22:00 on the previous day and ends at 22:00 on the current day.0930-1630:34567
starts at 09:30 and ends at 16:30 on Tuesday, Wednesday, Thursday, Friday, and Saturday.
First trading day
You can specify the first trading day of the week using semicolon:
1;0900-1630|0900-1400:2
— the first day of the week is Sunday.0900-1630|0900-1400:2;6
— the first day of the week is Saturday.0900-1630|0900-1400:2
— the first day of the week is Monday (default value).
Note about bar timestamps
The first bar timestamp coincides with the session opening time. All the following bar timestamps are calculated from the first one. For example, the session starts at 09:15, and the timestamp of the first bar is 09:15. The selected resolution is 1 hour. In this case, the second bar timestamp is 10:15, the third is 11:15, etc. If you want to display timestamps like [09:15, 10:00, 11:00,...]
, you should set session
to 0900-HHMM
and session_display
to 0915-HHMM
.
Examples
0900-1630|0900-1400:2
All week days except Mondays have one session that starts at 09:00 and ends at 16:30. A Monday's session starts at 09:00 and ends at 14:00.
Fragment Meaning 0900‑1630 A session 0900-1630. This session will be assigned by default to all non-weekend days because it's not followed by the :
specifier.| Sessions separator. This character divides different sessions. 0900‑1400 A session 0900-1400. It's the session for a day #2 (see below). : Day specifier. This character follows the session hours and is followed by the day numbers. 2 The day number for the session above (Monday). 1715F-0300,0915-1200,1300-1630:3456|1715F3-0300F2,0915-1200,1300-1630:2
Tuesday, Wednesday, Thursday, and Friday have three sessions. The first starts at 17:15 on the previous day and ends at 03:00 on the current day, the second starts at 09:15 on the current day and ends at 12:00, and the third starts at 13:00 and ends at 16:30.
Monday also has three sessions. The first starts at 17:15 on Friday and ends at 03:00 on Saturday, the second starts at 09:15 on Monday and ends at 12:00, and the third one starts at 13:00 and ends at 16:30.
Fragment Meaning 1715F‑0300 A session starts at 17:15 the day before and ends at 03:00. 0915‑1200 A session starts at 09:15 and ends at 12:00 . 1300‑1630 A session starts at 13:00 and ends at 16:30. : Day specifier. This character follows the session hours and is followed by the day numbers. 3456 The day numbers for the sessions above (Tuesday, Wednesday, Thursday, and Friday). | Sessions separator. This character divides different sessions. 1715F3‑0300F2 A session starts at 17:15 three days ago and ends at 03:00 two days ago. 0915‑1200 A session starts at 09:15 and ends at 12:00. 1300‑1630 A session starts at 13:00 and ends at 16:30. : Day specifier. 2 The day number for the session above (Monday).