Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculation Mode & Bars. Functionality

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

    Calculation Mode & Bars. Functionality

    Hello staff,

    When my strategy is set on Calculate.OnEachTick, does the Bars.IfFirstBarOfSession return true on the first tick of the session?
    And with the same calculation mode, does the "Bars.BarsSinceNewTradingDay > 1" access the first, albeit uncompleted bar of the day, or does it wait for at least 1 bar to have been printed for the particular day, and thus calculating on the second bar of the day?

    Thank you in advance for your time, I hope you guys at Ninjatrader have a great weekend.

    All the best,

    GLFX

    #2
    Hello GLFX005,

    The most simple way to answer these questions would be to use a Print and the NinjaScript output window. You could do a print like the following to observe these items:

    Code:
    Print(Bars.IsFirstBarOfSession + " " + IsFirstTickOfBar + " " + Bars.BarsSinceNewTradingDay);
    When my strategy is set on Calculate.OnEachTick, does the Bars.IfFirstBarOfSession return true on the first tick of the session?
    yes, using the above print you can see the following output where we see the first tick of the session:

    True True 0 <-- first tick
    True False 0
    True False 0
    True False 0
    True False 0
    True False 0
    does the "Bars.BarsSinceNewTradingDay > 1" access the first, albeit uncompleted bar of the day, or does it wait for at least 1 bar to have been printed for the particular day, and thus calculating on the second bar of the day?
    If you let the print run till the next bar you would see the following:

    True False 0 <-- last tick of bar
    False True 1 <-- first tick of bar
    False False 1
    It will only increment once the bar is closed and you are a bar away from the starting point.



    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    23 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X