Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Day ago

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

    Day ago

    Hello: I draw on the chart the value of the last variable of an indicator with Draw.TextFixed(this, "AVE", avg.ToString().........., but I want it to be the previous one in this daily chart case.

    The variable is avg = dynAverage[0];

    How do I get the previous value?

    #2
    Hello Gibranes,

    Thank you for your post.

    I see that you are drawing avg.ToString(). Since this is how avg is calculated for the current value:
    avg = dynAverage[0];

    To get the previous value, you would use a barsAgo index of 1:
    dynAverage[1]

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

    Comment


      #3
      If I set a value of 1 the indicator is not visible

      Code:
      protected override void OnBarUpdate()
              {
                  avg = dynAverage[0];
                  offset = stdDevNumber * dynStdDev [0];
                  PriceLine[0] = dynPrice[0];
                  SignalLine[0] = dynSignal[0];
                  Average[0] = avg;
                  Upper[0] = avg + offset;
                  Lower[0] = avg - offset;
      
                              valordiaanerior = Average[1]; // NOT WORK
                              
                              valordiaanerior = Average[0]; //  WORK
      
                  Draw.TextFixed(this, "AVE", valordiaanerior.ToString(), TextPosition.BottomLeft, Brushes.Red,........​

      Comment


        #4
        Originally posted by Gibranes View Post
        If I set a value of 1 the indicator is not visible

        Code:
        protected override void OnBarUpdate()
        {
        avg = dynAverage[0];
        offset = stdDevNumber * dynStdDev [0];
        PriceLine[0] = dynPrice[0];
        SignalLine[0] = dynSignal[0];
        Average[0] = avg;
        Upper[0] = avg + offset;
        Lower[0] = avg - offset;
        
        valordiaanerior = Average[1]; // NOT WORK
        
        valordiaanerior = Average[0]; // WORK
        
        Draw.TextFixed(this, "AVE", valordiaanerior.ToString(), TextPosition.BottomLeft, Brushes.Red,........​
        When you change it to 1, are there any errors on the Log tab of the Control Center? If so, what do the errors report?

        I look forward to your reply.

        Comment


          #5

          Calling error. You are accessing an index with an invalid value since it is out of range. That is, you have access to a series (barago) with a value of 5 when there are only four bars in the table​

          Comment


            #6
            Error calling.Onbarupdate method on bar 0

            Comment


              #7
              Originally posted by Gibranes View Post
              Calling error. You are accessing an index with an invalid value since it is out of range. That is, you have access to a series (barago) with a value of 5 when there are only four bars in the table​
              We have details about this error message here:


              Basically, you will have to make sure there are enough bars on the chart to be able to calculate the desired value. Since avg = dynAverage[0] and Average[0] = avg, to get Average[1] you need enough bars to calculate dynAverage[1]. You can add a check to see if there are enough bars as follows:
              Code:
              // if the current bar is less than the number of bars needed to get the value from 1 bar ago, return
              if (CurrentBar < // number of bars to get dynAverage[1])
              return;
              Please feel free to reach out with any additional questions or concerns.

              Comment


                #8
                I understand with a value greater than 5 it already works

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                589 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                342 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                555 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X