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 AveryFlynn, Today, 04:57 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by Max238, Today, 01:28 AM
    4 responses
    37 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by r68cervera, Today, 05:29 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by geddyisodin, Today, 05:20 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by timko, Today, 06:45 AM
    2 responses
    14 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Working...
    X