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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
670 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment