Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.LastBarOfSession always true

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

    Bars.LastBarOfSession always true

    Bars.LastBarOfSession always true when CalculateOnBarClose=true

    if that is correct behaviour what is the alternative?
    MicroTrends
    NinjaTrader Ecosystem Vendor - micro-trends.co.uk

    #2
    MicroTrends, I can't confirm this here in my tests run, which version / market / sessions are you using?

    also: this would be unfortunately not a supported NinjaScript functionality (not documented).

    You could check for the hours of the template applied with the GetNextSessionBeginEnd:

    Comment


      #3
      Just responding as I had tested this before, and it works on my side.

      Have added an indicator to test it, which I still have on my installation.
      Attached Files

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        MicroTrends, I can't confirm this here in my tests run, which version / market / sessions are you using?

        also: this would be unfortunately not a supported NinjaScript functionality (not documented).

        You could check for the hours of the template applied with the GetNextSessionBeginEnd:

        http://www.ninjatrader.com/support/h...t7/session.htm
        The error occurs using MBTrading FX Datafeed
        Delete the Forex sesison template
        use the 24/7 Template
        Set calculatebaronclose =false;

        test on barupdate
        MicroTrends
        NinjaTrader Ecosystem Vendor - micro-trends.co.uk

        Comment


          #5
          Actually i thinnk it was a PFGBEST cme session or a 24/5 sesison for futures....I will have to dig:-)
          MicroTrends
          NinjaTrader Ecosystem Vendor - micro-trends.co.uk

          Comment


            #6
            ok i remembered:

            Harry's indicator shows the issue visually:

            It works as normal on a chart but, the issue is created by the adidtion of a strategy.with calculateonbarclose set to false

            Last edited by MicroTrends; 05-20-2011, 03:49 AM.
            MicroTrends
            NinjaTrader Ecosystem Vendor - micro-trends.co.uk

            Comment


              #7
              Could reproduce bug over here

              The bug is easy to reproduce. Just add the indicator below to a virgin chart and use it with real-time data and CalculateOnBarClose = false setting.

              NinjaTrader will now identify every real-time bar as last bar of session, see chart below.
              The bug also showed on index futures.
              Attached Files
              Last edited by Harry; 05-20-2011, 04:09 AM.

              Comment


                #8
                Thank you for your help Harry.
                MicroTrends
                NinjaTrader Ecosystem Vendor - micro-trends.co.uk

                Comment


                  #9
                  MicroTrends and Harry,

                  This is not a supported property that you guys are using for the exact reason as you guys have outlined in this thread. In our source code we specifically have notes commented on it that says it would always be true for the right-most bar making it pretty much unusable for real-time strategies.

                  Unfortunately we will not be able to make any changes to this property.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Bars.LastBarOfSession

                    I would like a live strategy to perform a certain action after it has processed all its historical bars.
                    In a backtest, one can use "OnTermination", but a live strategy ( on a chart, CalculateOnBarClose = false ) doesn't receive that unless and until the strategy is disabled.
                    Normally I would just have the strategy act upon the first "OnBarUpdate" to arrive, but under extra-market conditions, for example, those can be few and far between and I can't wait for them, so I'd like the strategy to be able to immediately act upon "knowing" it has processed its last historical bar.
                    Would "Bars.LastBarOfSession", although unsupported, be useful here ? There's no documentation to refer to, but it would seem a property like this might exist mainly for these purposes.

                    Comment


                      #11
                      Hello Shogun SunTzu,

                      I believe Historical property should work for you.

                      It's used in the example below to exclude processing on Historical bars and only work on real time data.

                      if (Historical) return;

                      If you want some historical processing but not for a specific condition, use:
                      if (!Historical)
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by Shogun SunTzu View Post
                        [FONT=Verdana][SIZE=3]I would like a live strategy to perform a certain action after it has processed all its historical bars.
                        Try this....


                        Code:
                        protected override void OnBarUpdate()
                         {
                        	if (LastBarOnChart) Print "We're on the last bar";
                        }
                        
                        // Returns true if processing last bar added to chart.
                        //
                        private bool LastBarOnChart
                        {
                        	get
                        	{
                        		return( Historical && (CurrentBar == (Bars.Count - 1 - (CalculateOnBarClose ? 1 : 0 )) ));	// Return TRUE if at the last historical bar of the chart.
                        	}
                        }
                        /

                        Comment


                          #13
                          Will KBJ's 'LastBarOnChart' method work on end of day delayed data like the free Kinetic feed? I can't seem to make it work on my charts (with free Kinetic data... ). Unfortunately, I don't yet have real time data to test this problem.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          648 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          369 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          572 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          573 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X