Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DaysToLoad

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

    DaysToLoad


    I need the equivalent of "Bars.BarsData.DaysBack" from NT7 to NT8

    I tried DaysBack from the help guide but it won't work.


    Thank you!


    #2
    Originally posted by Danville.Sumobay View Post
    I need the equivalent of "Bars.BarsData.DaysBack" from NT7 to NT8

    I tried DaysBack from the help guide but it won't work.
    Won't work how?

    ChartBars.DaysBack doesn't work?

    Can you post your code?

    Comment


      #3

      I got an error when added that to my script.

      'NinjaTrader.Gui.Chart.ChartBars' does not contain a definition for 'DaysBack' and no extension method 'DaysBack' accepting a first argument of type 'NinjaTrader.Gui.Chart.ChartBars' could be found (are you missing a using directive or an assembly reference?)



      Thanks

      Comment


        #4
        Hello Danville.Sumobay,

        Thank you for your reply.

        Could you please post a sample snippet of the code in question that is not compiling?

        Thanks in advance; I look forward to assisting you further.

        Comment


          #5
          Thank you for your response,

          I simply add this line for NT8

          int d = ChartBars.DaysBack; //this produce an error

          While I had no problem this equivalent in NT7 with the following

          int d = Bars.BarsData.DaysBack;

          Comment


            #6
            Hello Danville.Sumobay,

            Thank you for your reply.

            We need a little more context here. Where in your code does this occur? Is this inside OnBarUpdate()? Elsewhere? If you could provide a larger code sample that would be helpful in discerning the context.

            Thanks in advance; I look forward to assisting you further.

            Comment


              #7
              Yes, it is inside the OnBarUpdate()


              protected override void OnBarUpdate()
              {
              if (BarsArray[0].BarsType.IsRemoveLastBarSupported)
              {
              if (CurrentBar == 0)
              Value[0] = Input[0];
              else
              {
              double last = Value[1] * Math.Min(CurrentBar, Period);

              if (CurrentBar >= Period)
              Value[0] = (last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period);
              else
              Value[0] = ((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
              }
              }
              else
              {
              if (IsFirstTickOfBar)
              priorSum = sum;

              sum = priorSum + Input[0] - (CurrentBar >= Period ? Input[Period] : 0);
              Value[0] = sum / (CurrentBar < Period ? CurrentBar + 1 : Period);
              }

              int d = ChartBars.DaysBack;

              Print("DaysToLoad: "+d);
              }

              I saw "DaysBack" on the documentation but I don't know how to apply.


              Thanks

              Comment


                #8
                Hello Danville.Sumobay,

                Thank you for your reply.

                You're trying to use ChartBars.DaysBack, but the correct syntax here for that would be ChartBars.Properties.DaysBack.

                One note: I would recommend using full brackets with your if/else statements, like this:

                if (some condition)
                {
                // do something
                }
                else
                {
                // do something else
                }

                This will help better structure your code. You can omit brackets if it's just one line after the if statement, as in:

                if (CurrentBar < Period)
                return;

                Otherwise, I recommend using both opening and closing brackets, otherwise things can get confusing quickly.

                Please let us know if we may be of further assistance to you.

                Comment


                  #9
                  Originally posted by NinjaTrader_Kate View Post
                  the correct syntax here for that would be ChartBars.Properties.DaysBack.
                  Really? That simple, huh?

                  Gee, hard to know that, since the documentation does not have a SINGLE example of the usage.

                  I had even grepped every NT8 indicator, searching for an example of DaysBack ... no joy.

                  When you add up all the time wasted for every person affected because of insufficient documentation, it boggles the mind.

                  Unfortunately, there is still no substitute for live and learn.




                  Comment


                    #10
                    Thank you!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    647 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    368 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
                    571 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