Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.Session.GetNextBeginEnd()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Bars.Session.GetNextBeginEnd()

    Ho do we rewrite he following in NT 8
    Bars.Session.GetNextBeginEnd(bars ,barsAgo, out cacheSessionBeginTmp, out cacheSessionEndTmp)

    #2
    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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    24 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    14 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    19 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    135 views
    0 likes
    Last Post SalmaTrader  
    Working...
    X