Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Condition for new Session start

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

    Condition for new Session start

    My backtest program recalculates variables whenever a new Session starts, for historical bars.

    Is there a straightforward way to specify this condition?

    Thanks.


    Condor Alpha Asset Management

    #2
    Hello yubo27,

    You can you the "Bars.FirstBarOfSession" to be able to find out which bar is the start of a new session.
    http://www.ninjatrader.com/support/h...rofsession.htm
    JCNinjaTrader Customer Service

    Comment


      #3
      Condition if(Bars.FirstBarOfSession) in OnBarUpdate gives error "Cannot convert method group 'IsFirstBarOfSession' to non-delegate type 'bool'. Did you intend to invoke the method? CS0428".

      What's the correct way to refer to Bars object in OnBarUpdate ?

      Comment


        #4
        Got it.

        Bars.IsFirstBarOfSession(0)

        Comment


          #5
          Hello yubo27,

          You can do the following statement:

          Code:
          // At the start of a new session
          if (Bars.FirstBarOfSession)
          {
          	//Do something
          }
          The following link you may use as a reference that uses the "Bars.FirstBarOfSession".

          http://www.ninjatrader.com/support/f...ead.php?t=4084
          JCNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          68 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          37 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          61 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          62 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          53 views
          0 likes
          Last Post CarlTrading  
          Working...
          X