Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

BarsSinceSession Conversion

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

    BarsSinceSession Conversion

    Dear Support,

    What is the NT8 conversion for the following NT7 bar index?:

    Code:
                 int barsSince = Bars.BarsSinceSession;
    There is no code breaking for Bars.BarsSinceSession in "Help." However, there is a Bars.BarsSinceNewTradingDay, but I'm not sure produces the same results since new trading day is not the same as session.

    Many Thanks.

    #2
    Hello aligator,

    Thanks for your post.

    With reference to the code-breaking change section of the help guide, BarsSinceNewTradingDay is the NT8 equivalent of the NT7 BarsSinceSession:

    Click image for larger version

Name:	Alligator-1.PNG
Views:	329
Size:	5.7 KB
ID:	1059272 Reference: https://ninjatrader.com/support/help...ng_changes.htm


    If you are using a multisession trading day and want to keep track of the bars since each session begins, you can use the bool IsFirstBarOfSession as a starting point to set an int type counter and update the counter on each new bar.

    For example:

    if (Bars.IsFirstBarOfSession)
    {
    myBarsSinceSession = 1; // set/reset counter on each new session (you would need to create myBarsSinceSession as an int type variable)
    }

    if (IsFirstTickOfBar)
    {
    myBarsSinceSession++; // increment counter
    }


    References:

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello aligator,

      Thanks for your post.

      With reference to the code-breaking change section of the help guide, BarsSinceNewTradingDay is the NT8 equivalent of the NT7 BarsSinceSession:

      Click image for larger version

Name:	Alligator-1.PNG
Views:	329
Size:	5.7 KB
ID:	1059272 Reference: https://ninjatrader.com/support/help...ng_changes.htm


      If you are using a multisession trading day and want to keep track of the bars since each session begins, you can use the bool IsFirstBarOfSession as a starting point to set an int type counter and update the counter on each new bar.

      For example:

      if (Bars.IsFirstBarOfSession)
      {
      myBarsSinceSession = 1; // set/reset counter on each new session (you would need to create myBarsSinceSession as an int type variable)
      }

      if (IsFirstTickOfBar)
      {
      myBarsSinceSession++; // increment counter
      }


      References:

      https://ninjatrader.com/support/help...ttickofbar.htm
      Thank you so much Paul.

      Cheers!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by frankthearm, Today, 09:08 AM
      5 responses
      14 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      43 views
      0 likes
      Last Post jeronymite  
      Started by yertle, Today, 08:38 AM
      5 responses
      15 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by adeelshahzad, Today, 03:54 AM
      3 responses
      19 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by bill2023, Yesterday, 08:51 AM
      6 responses
      27 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X