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 Mindset, Today, 06:46 AM
    0 responses
    8 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, Yesterday, 05:21 PM
    0 responses
    12 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    15 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    82 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    47 views
    0 likes
    Last Post PaulMohn  
    Working...
    X