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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    48 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X