• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 05: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;
            }
    Patrick H.NinjaTrader Customer Service

    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 Bionian, Yesterday, 11:47 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by Gerik, Today, 12:14 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by mestril, Today, 06:00 AM
        0 responses
        6 views
        0 likes
        Last Post mestril
        by mestril
         
        Started by Goolden, Today, 05:47 AM
        0 responses
        5 views
        0 likes
        Last Post Goolden
        by Goolden
         
        Started by kujista, Today, 12:59 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Working...
        X