Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Pivots to the Pivot Indicator

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

    Adding Pivots to the Pivot Indicator

    As I'm a novice at C, I try to build on the existing Ninja scripts.
    I took the "Pivots" script and changed the values to use it for creating Fibonacci horizontal lines. That worked fine.
    Now I'm trying to add two additional lines. I've tried both extended lines and internal lines. The script compiles without errors but now no lines show up.
    If you could take a look at the script and point me in the right direction, I would be very appreciative.
    Attached Files

    #2
    sgordet,

    Can you please clarify exactly where in your code you have added these lines? Can you post a snippet of the signature you are using?

    When you apply this indicator to a chart, do you get any errors on the Log tab of the Control Center? If so, what do these errors report?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks, Matt.
      I found the error message in the log:
      Error on plotting indicator. Check the OnBarUpdate or the "Plot" method. Index was outside the bounds of the array.

      Changes I made:
      Added two variables for the lines and defined them..
      Added two plots.
      Added two set statements.
      Added the two dataseries in Properties.

      I don't understand what the "signature" is or I would post a snipped of it as requested.

      It sounds from the error message that the problem is that I didn't expand the array that holds the added lines, but I can't find where it's declared.

      Comment


        #4
        Hello,

        Can you post the plots that you added?
        MatthewNinjaTrader Product Management

        Comment


          #5
          All of the code is the same as the original Pivots indicator except for the formulas for arriving at each of the pivots, which works fine as long as I don't add any new pivots

          These are all of the new code lines. They were added directly after each of the R3 and S3 statements:

          Variables
          privatedouble s4 = 0;
          privatedouble s4 = 0;

          Initialize
          Add(new Plot(new Pen (Color.Blue,2), "R4"));
          Add(
          new Plot(new Pen (Color.Red,2), "S4"));

          OnBarUpdate
          s4 = pp - (currentHigh - currentLow) * .8;
          r4 = pp + (currentHigh - currentLow)*
          .8;

          R4.Set(r4);
          S4.Set(s4);

          [Browsable(false)]
          [XmlIgnore]
          public DataSeries R4
          {
          get { return Values[7]; }
          }

          [Browsable(false)]
          [XmlIgnore]
          public DataSeries S4
          {
          get { return Values[8]; }


          Comment


            #6
            Originally posted by sgordet View Post
            Thanks, Matt.
            I found the error message in the log:
            Error on plotting indicator. Check the OnBarUpdate or the "Plot" method. Index was outside the bounds of the array.

            Changes I made:
            Added two variables for the lines and defined them..
            Added two plots.
            Added two set statements.
            Added the two dataseries in Properties.

            I don't understand what the "signature" is or I would post a snipped of it as requested.

            It sounds from the error message that the problem is that I didn't expand the array that holds the added lines, but I can't find where it's declared.
            That indicator uses a custom Plot override, so you need to make sure that you are providing the correct input to the Plot() method. In this case, you must have as many brushes are there are lines, so you need to add the correct number of brushes to the brushes collection/array.

            Add the correct number of brushes to this line thus:


            Code:
            		private	SolidBrush[]		brushes				= { new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black)};
            I added 2 brushes.

            Comment


              #7
              Thanks a million, Koganam. That did it!

              Stephen

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by amichalska, Today, 01:23 PM
              2 responses
              14 views
              0 likes
              Last Post amichalska  
              Started by GreyKerns09, Today, 03:42 PM
              0 responses
              5 views
              0 likes
              Last Post GreyKerns09  
              Started by PrTester, 12-29-2008, 05:27 PM
              133 responses
              96,726 views
              0 likes
              Last Post aligator  
              Started by ETFVoyageur, Yesterday, 12:26 PM
              6 responses
              29 views
              0 likes
              Last Post ETFVoyageur  
              Started by ETFVoyageur, 05-18-2024, 12:45 AM
              12 responses
              67 views
              0 likes
              Last Post ETFVoyageur  
              Working...
              X