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 CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
24 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
25 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|
||
|
Started by CaptainJack, 03-25-2026, 09:53 PM
|
0 responses
30 views
0 likes
|
Last Post
by CaptainJack
03-25-2026, 09:53 PM
|
||
|
Started by CaptainJack, 03-25-2026, 09:51 PM
|
0 responses
18 views
0 likes
|
Last Post
by CaptainJack
03-25-2026, 09:51 PM
|
||
|
Started by Mindset, 03-23-2026, 11:13 AM
|
0 responses
27 views
0 likes
|
Last Post
by Mindset
03-23-2026, 11:13 AM
|

Comment