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 CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
45 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
30 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
99 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
177 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
170 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Comment