Bars.Session.GetNextBeginEnd(bars ,barsAgo, out cacheSessionBeginTmp, out cacheSessionEndTmp)
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bars.Session.GetNextBeginEnd()
Collapse
X
-
You will need to use the Bars.SessionIterator. If you do not calculate the trading day using GetNextSession(), the SessionIterator will only provide you real-time session information. However, you will want to use GetNextSession() sparingly as it is a pretty cpu expensive method
Code:private DateTime sessionBegin; private DateTime sessionEnd; protected override void OnBarUpdate() { if (Bars.IsFirstBarOfSession) { //you must calculate the next session based on the current bar time Bars.SessionIterator.GetNextSession(Time[0], true); //otherwise these values will only calculate the current day session... sessionBegin = Bars.SessionIterator.ActualSessionBegin; sessionEnd = Bars.SessionIterator.ActualSessionEnd; Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd); } }MatthewNinjaTrader Product Management
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, Today, 06:46 AM
|
0 responses
8 views
0 likes
|
Last Post
by Mindset
Today, 06:46 AM
|
||
|
Started by M4ndoo, Yesterday, 05:21 PM
|
0 responses
12 views
0 likes
|
Last Post
by M4ndoo
Yesterday, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
15 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
82 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
47 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment