Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Percentage of a time period

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

    Percentage of a time period

    Good afternoon.

    I need to express in c # the% rise or fall in a period that is a (Variable)



    For example compare the percentage so close to previous close, but I need to compare last sealing with a period that can be a variable, get percentage rise or fall from a particular time period.
    100 * ((Close [0]-Close [0]) / Close [0]) ;/ / closures Percent

    Greetings.

    #2
    Hello optimuss,

    Could you clarify, are you wanting to compare the current/last close price to the average of the Close price over a period?

    As it looks like now you are getting the difference of two different periods and trying to get the difference percentage from the current/last close which will probably very small.
    JCNinjaTrader Customer Service

    Comment


      #3
      Originally posted by optimuss View Post
      Good afternoon.

      I need to express in c # the% rise or fall in a period that is a (Variable)



      For example compare the percentage so close to previous close, but I need to compare last sealing with a period that can be a variable, get percentage rise or fall from a particular time period.
      100 * ((Close [0]-Close [0]) / Close [0]) ;/ / closures Percent

      Greetings.
      Is that not just
      Code:
      Plot0.Set(100 * ((Close [0]-Close [VarPeriod]) / Close [VarPeriod]) ;
      ?
      Last edited by koganam; 07-20-2013, 01:50 PM.

      Comment


        #4
        Hello NinjaTrader_JC koganam and thanks to you for your help and sorry for the late reply.

        Seeking to obtain the percentage change close [variable] to close [0], not the average, if the accumulated.

        I'm trying to do;
        Plot0.Set (100 * ((Close [0] Close [VarPeriod]) / Close [VarPeriod]));
        koganam so it is not possible, the indicator does not take any values ​​so this expression.

        As would have to say to get the cumulative percentage from?
        close [variable] to close [0]?.

        Thank you.

        Comment


          #5
          Originally posted by optimuss View Post
          Hello NinjaTrader_JC koganam and thanks to you for your help and sorry for the late reply.

          Seeking to obtain the percentage change close [variable] to close [0], not the average, if the accumulated.

          I'm trying to do;
          Plot0.Set (100 * ((Close [0] Close [VarPeriod]) / Close [VarPeriod]));
          koganam so it is not possible, the indicator does not take any values ​​so this expression.

          As would have to say to get the cumulative percentage from?
          close [variable] to close [0]?.

          Thank you.
          That may be why I am confused. I certainly am lost with what you intend to do. The percentage change in price from VarPeriod ago to the current bar is identically:
          Code:
          100 * ((Close [0]-Close [VarPeriod]) / Close [VarPeriod])
          What you actually want to do with it is a different kettle of fish. I just assumed that you wanted to plot it, so set it to a Plot(). Incidentally, that IS the correct statement; what you posted is semantically incorrect.

          Comment


            #6
            Koganam Hello, thank you very much for your help.

            Take a sight to see as this as what you say, if you insert well in graphic indicator does not return any value ..

            Garcias.
            Attached Files

            Comment


              #7
              Originally posted by optimuss View Post
              Koganam Hello, thank you very much for your help.

              Take a sight to see as this as what you say, if you insert well in graphic indicator does not return any value ..

              Garcias.
              That is a different issue.

              Look in your log, and you will see the error. Search this forum using the error, and you will find many threads with the solution. It has to do with your not having enough bars when you first try to do the calculation.

              Try putting:
              Code:
              if (CurrentBar < VarPeriod) return;
              at the top of your OnBarUpdate() handler.

              Comment


                #8
                woooo, that's right! sometimes they do not give importance to that instruction.

                Many thanks friend for your great help.


                Best wishes.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                656 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                371 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                579 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X