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 JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Working...
        X