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

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.



    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sidlercom80, 10-28-2023, 08:49 AM
    170 responses
    2,271 views
    0 likes
    Last Post sidlercom80  
    Started by Irukandji, Yesterday, 02:53 AM
    2 responses
    17 views
    0 likes
    Last Post Irukandji  
    Started by adeelshahzad, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post adeelshahzad  
    Started by CortexZenUSA, Today, 12:53 AM
    0 responses
    3 views
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Working...
    X