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 Mestor, 03-10-2023, 01:50 AM
        16 responses
        388 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        29 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        22 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        7 views
        0 likes
        Last Post funk10101  
        Working...
        X