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 SnailHorn, Yesterday, 10:49 PM
|
1 response
10 views
0 likes
|
Last Post
by SnailHorn
Today, 03:59 AM
|
||
Started by manueldecastro, Yesterday, 10:26 AM
|
4 responses
20 views
0 likes
|
Last Post Today, 02:56 AM | ||
Started by TraderIqbal, 10-20-2023, 10:12 AM
|
2 responses
119 views
0 likes
|
Last Post
by Funnywo
Today, 02:03 AM
|
||
Started by Creamers, 04-27-2024, 05:32 AM
|
12 responses
72 views
0 likes
|
Last Post
by Creamers
Today, 01:50 AM
|
||
Started by fredericlebre, Today, 01:19 AM
|
0 responses
10 views
0 likes
|
Last Post Today, 01:19 AM |
Comment