• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Highest Close of the Last n bars

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

    Highest Close of the Last n bars

    Is there a command like Highest (close, nbars)?

    How would I go about finding the "Highest Close" of the last "n" bars in C#?

    Thanks

    #2
    Originally posted by randl View Post
    Is there a command like Highest (close, nbars)?

    How would I go about finding the "Highest Close" of the last "n" bars in C#?

    Thanks
    Look at the MAX() class.

    ref: http://www.ninjatrader.com/support/h...aximum_max.htm

    Comment


      #3
      Hello randl,

      Thank you for your post.

      You can also use High[HighestBar(High, nbars)]. For information on HighestBar() please visit the following link: http://www.ninjatrader.com/support/h...highestbar.htm

      Please let me know if I may be of further assistance.
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        Thanks Patrick, can you tell me if this statement will plot correctly for the original question I asked and the data you gave me?

        Plot0.Set((HighestBar(Close, Bars.BarsSinceSession - 22).ToString()- Low)/ ((HighestBar(Close, Bars.BarsSinceSession - 22).ToString()))* 100

        Comment


          #5
          Hello randl,

          Thank you for your response.

          The HighestBar() is an int, so if the intent behind your Plot.Set() is for a y value representing price you will need to call the HighestBar() as the barsAgo index for the High:
          Code:
          Plot.Set(((High[HighestBar(Close, Bars.BarsSinceSession - 22)] - Low[0])/(High[HighestBar(Close, Bars.BarsSinceSession - 22)])) * 100);
          Patrick H.NinjaTrader Customer Service

          Comment


            #6
            Thanks Patrick, I ran the string you suggested and got the following error message. I am missing something else.

            Indicator\WVF.cs 'NinjaTrader.Indicator.IndicatorBase.Plot(System.D rawing.Graphics, System.Drawing.Rectangle, double, double)' is a 'method', which is not valid in the given context CS0119 - click for info Row 46 Column 13

            Comment


              #7
              I also tried this and got these error messages:

              NinjaScript --> File --> Error --> Code --> Line --> Column
              Indicator\WVF.cs Cannot assign to 'WVF' because it is a 'method group' CS1656 - click for info 46 4
              Indicator\WVF.cs 'NinjaTrader.Indicator.IndicatorBase.Plot(System.D rawing.Graphics, System.Drawing.Rectangle, double, double)' is a 'method', which is not valid in the given context CS0119 - click for info 47 13

              Any ideas what I defined wrong?
              Thanks

              Comment


                #8
                Hello randl,

                Thank you for your response.

                If there is one Plot try using Value.Set() rather than Plot.Set(). If there are multiple plots you will need to call the correct name for each plot or use Values.

                For information on Value and Values please visit the following links:
                For a tutorial on plots in NinjaScript please visit the following link: http://www.ninjatrader.com/support/h...ot_colors_.htm

                Please let me know if I may be of further assistance.
                Patrick H.NinjaTrader Customer Service

                Comment


                  #9
                  thanks Patrick, I saw the example give but I did not understand it well enough to use it. what is it checking?
                  Thanks

                  Comment


                    #10
                    Hello randl,

                    Thank you for your response.

                    The Tutorial shows how to change plots based on the ROC above or below the zero line.
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #11
                      Sorry Patrick I don't know what ROC is.

                      There is no above or below the zero line in my case. All I want is to do is to continually check for the highest close of the last 22 bars and subtract the current low from it, then divide it by the highest close of the last 22 bars and multiply it by 100.

                      Comment


                        #12
                        Hello randl,

                        Thank you for your response.

                        The tutorial also serves as an example of setting up Plots. How many plots do you have in your code?
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          One - just the plot generated by the equation.
                          Thanks for getting back to me.

                          Comment


                            #14
                            Originally posted by randl View Post
                            Sorry Patrick I don't know what ROC is.

                            There is no above or below the zero line in my case. All I want is to do is to continually check for the highest close of the last 22 bars and subtract the current low from it, then divide it by the highest close of the last 22 bars and multiply it by 100.
                            If you had followed my advice to look at the MAX() class, you would have seen that you can do that in one line, thus:
                            Code:
                            Plot0.Set(100 * (MAX(High, 22)[0] - Low[0]) / MAX(Close, 22)[0]);

                            If your "last" does not include the CurrentBar, then you would index the MAX() terms to [1] instead of [0].
                            Last edited by koganam; 11-04-2013, 01:51 PM.

                            Comment


                              #15
                              Thanks Koganam, that worked.

                              Sorry, I must have missed your post over the weekend.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Sank1, Today, 01:58 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_PatrickG  
                              Started by GARZONJ, Today, 12:50 PM
                              2 responses
                              8 views
                              0 likes
                              Last Post GARZONJ
                              by GARZONJ
                               
                              Started by guigs88, Today, 12:45 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Started by FREEN, 08-13-2019, 09:18 AM
                              5 responses
                              28 views
                              0 likes
                              Last Post koganam
                              by koganam
                               
                              Started by U0000999, Today, 12:43 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jim  
                              Working...
                              X