Trading sessions
Since the release of cTrader Windows 4.5, the API includes the MarketSessions interface. It allows you to get information about current market sessions and using this data in your cBots and indicators.
Trading sessions in algo development
The MarketSession type is an enum with values representing various trading sessions (such as Singapore or London).
In turn, the MarketSessions property is of the MarketSession type. To get all current market sessions, use it as follows.
1 | |
The value of the MarketSessions property should match the sessions that are displayed in the Trading sessions field in the lower-left corner of the cTrader UI.

You can use the HasFlag method to check whether the current sessions contain a specific session.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
You can also handle the MarketSessionsChanged event to detect and react to any changes in market sessions. The MarketSessionChangedEventArgs class has two properties, namely NewSessions and PreviousSessions, which work as follows:
NewSessionscontains all current sessions including any sessions that have just started. The value ofNewSessionsis always equal to the value of theMarketSessionsproperty of a cBot or indicator.PreviousSessionsalso contains all current sessions but it also contains any past sessions that have just ended. Its value is equal to the value of theMarketSessionsproperty of a cBot or indicator before theMarketSessionsChangedwas triggered.
For a more detailed look at how NewSessions and PreviousSessions work, refer to the example below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
In the log, you should see two new entries for each session change. These entries will inform you of what the past trading sessions were and what they are now.
Trading sessions during backtesting
The MarketSessions property works on both live and backtesting environments. During backtesting, this property will contain the sessions relative to the chosen backtest timings. In other words, you can use it to access trading sessions that were active during a specific historic trading period.