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

Ninjatrader have function to get all bars from previous trading day?

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

    Ninjatrader have function to get all bars from previous trading day?

    DateTime.today.addDays(-1) - bad solution, because previous day can be sunday.
    Count bars for each time frame bad solution.
    Maybe Ninjatrader have function to get all bars from previous trading day (or session or how you call this...)?
    Last edited by nordseven; 02-15-2016, 06:21 AM.

    #2
    Hello nordseven,

    Thank you for your note.

    You could use GetNextBeginEnd of the session: http://ninjatrader.com/support/helpG...xtbeginend.htm

    Or you could track the current day value and store it. For example:
    Code:
            #region Variables
            private DateTime today;
    		private DateTime yesterday;
            #endregion
    
            /// <summary>
            /// This method is used to configure the indicator and is called once before any bar data is loaded.
            /// </summary>
            protected override void Initialize()
            {
                
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                if (Bars.FirstBarOfSession)
    			{
    				yesterday = today;
    				today = Time[0];
    			}
    			if (today == yesterday)
    				return;
            }

    Comment


      #3
      Originally posted by nordseven View Post
      DateTime.today.addDays(-1) - bad solution, because previous day can be sunday.
      Count bars for each time frame bad solution.
      Maybe Ninjatrader have function to get all bars from previous trading day (or session or how you call this...)?
      The Pivots indicator might have code for what you're looking for.

      Comment


        #4
        Thank you for answer. Solve problem with addDays(-1) and checking DayOfWeek and Holidays.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fitspressoburnfat, Today, 04:25 AM
        0 responses
        2 views
        0 likes
        Last Post fitspressoburnfat  
        Started by Skifree, Today, 03:41 AM
        1 response
        4 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by usazencort, Today, 01:16 AM
        0 responses
        1 view
        0 likes
        Last Post usazencort  
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        604 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        23 views
        0 likes
        Last Post xiinteractive  
        Working...
        X