Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Default plot width of the line indicator

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

    Default plot width of the line indicator

    Hi All,

    How can I set indicator plot width as default 3. Currently default value 1.

    Any suggestions?

    Thanks!!

    Antony

    #2
    Hello Antony,

    Thank you for your post.

    Within the Initialize() method after adding your plots you can define the Pen Width.
    Example:
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "PlotName"));
    Plots[0].Pen.Width = 3;
    }


    For a reference on Multi-Colored Plots which includes the use of "Plots[0].Pen.Width..." please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3227

    For information on the Pen class please visit the following link: http://msdn.microsoft.com/en-us/libr...xw(vs.71).aspx

    To set the width without programming you can right click within your chart > select Indicators > select the indicator you wish to change > on the right hand side of the Indicators window you will see the 'Plots' section > left click on the '+' next to the plot you wish to change > make your changes > right click within the right side of the Indicators window > select 'Set Default For "Indicator Name"'.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Thanks a lot...

      It's working well.

      Thanks!!

      Antony.

      Comment


        #4
        I have an oscillator, we'll say a CCI, and I want the plot thickness to be 1, unless it is over 200. I then want it to be 3 thickness. So I have all that. However, after the first instance of the if statement turning the plot into size 3, it doesn't go back to size 1.

        The stochastics Color indicator I believe used 3 plots to avoid the problem I seem to be having. How can I reset the plot to 1 after it no longer fulfills the condition that caused it change to size 3? Hopefully this makes sense...

        Comment


          #5
          Hello jmflukeiii,

          Thank you for your post.

          Please provide the conditions used to change the width of the Plot to 3 and 1 in your response.

          I look forward to assisting you further.

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello jmflukeiii,

            Thank you for your post.

            Please provide the conditions used to change the width of the Plot to 3 and 1 in your response.

            I look forward to assisting you further.
            if(CCI>200)
            {Plots[0][0].Pen.Width = 3'}
            If(CCI<200)
            {Plots[0][0].Pen.Width = 3;}
            else
            {Plots[0][0].Pen.Width = 1;}

            Comment


              #7
              Originally posted by jmflukeiii View Post
              if(CCI>200)
              {Plots[0][0].Pen.Width = 3'}
              If(CCI<200)
              {Plots[0][0].Pen.Width = 3;}
              else
              {Plots[0][0].Pen.Width = 1;}
              It is doing as you asked it to.
              First statement: If CCI is greater than 200, set Plot thickness to 3.
              Second statement: If CCI is less than 200 set Plot thickness to 3.

              As CCI must needs be either greater than or less than 200, unless it is exactly 200, the or third statement is never going to be reached. If you can find anywhere where the CCI is exactly 200.000000000000, then the thickness will be 1.

              Perchance what you have coded is not really what you meant logically?

              Comment


                #8
                Typo there - less than NEGATIVE 200, set to 3. But that was a typo only in my writing here.

                Thanks for the response though Koganam - I am trying to acheive a similar effect to the Stochastics Color indicator, but with the CCI. I am stumped though with the Stochastic one (its on ninja's forum) - I do not understand what makes it prints a different color above 80/below 20.

                I did what I thought it was doing, which was using separate plots - i.e.
                if CCI>200, Above200.Set(CCI[0])
                else if CCI <-200, Below200.Set(CCI[0].)
                else CCIPlot.Set(CCI[0])

                The problem with this is it creates holes in the plot in between the transfer from below 200 to above 200 (and on the negative side).
                Last edited by jmflukeiii; 04-06-2013, 11:40 AM.

                Comment


                  #9
                  Originally posted by jmflukeiii View Post
                  Typo there - less than NEGATIVE 200, set to 3. But that was a typo only in my writing here.

                  Thanks for the response though Koganam - I am trying to acheive a similar effect to the Stochastics Color indicator, but with the CCI. I am stumped though with the Stochastic one (its on ninja's forum) - I do not understand what makes it prints a different color above 80/below 20.

                  I did what I thought it was doing, which was using separate plots - i.e.
                  if CCI>200, SetAbove200.CCI[0],
                  else if CCI <-200, SetBelow200.CCI[0].
                  else SetCCIPlot.CCI[0].

                  The problem with this is it creates holes in the plot in between the transfer from below 200 to above 200 (and on the negative side).
                  One way is to make your Plots repaint at the transition, by checking for it, then setting the thicker Plot one place back to the same value as the thinner Plot.

                  The other way would be to set all 3 Plots at each point, making the ones that you will not display to be Color.Empty or Color.Transparent.

                  Comment


                    #10
                    This works for the line colors perfectly - no gapping. But the thickness doesn't change??? I don't understand why I'm having such problems with such a simple thing:


                    if
                    (CCI(period)[0]>-200 && CCI(period)[0]<200)
                    {
                    Plots[
                    0].Pen.Width = 2;
                    PlotColors[
                    0][0] = Color.Turquoise;
                    }
                    elseif (CCI(period)[0]>=200)
                    {
                    PlotColors[
                    0][0] = Color.Red;
                    Plots[
                    0].Pen.Width = 5;
                    }
                    elseif (CCI(period)[0]<=-200)
                    {
                    PlotColors[
                    0][0] = Color.Green;
                    Plots[
                    0].Pen.Width = 5;
                    }

                    Comment


                      #11
                      Originally posted by jmflukeiii View Post
                      This works for the line colors perfectly - no gapping. But the thickness doesn't change??? I don't understand why I'm having such problems with such a simple thing:
                      Without running the code, I would still expect that your Plot thickness is changing for its entire existing length. That is what I would expect because the Plot's pen is a property of the Plot, not of the segment. PlotColors is designed to be handled per segment.

                      You will probably have to use one of the 3 Plots methods that I outlined.

                      Comment


                        #12
                        Here's the indicator - if you have the time, I'd appreciate if you take a look. I tried your second method, but didn't spend much time on it. It just kept plotting all 3 all the time.
                        Attached Files

                        Comment


                          #13
                          Originally posted by jmflukeiii View Post
                          Here's the indicator - if you have the time, I'd appreciate if you take a look. I tried your second method, but didn't spend much time on it. It just kept plotting all 3 all the time.
                          There must be some mistake: this is not what I said; this is what you posted, to which I responded. Did you post the wrong file?

                          Comment


                            #14
                            Sorry - I just posted my version in response to you saying something along the lines of 'you couldn't do anything more without the script' or something to that effect. Don't worry about - thanks for your help

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by caacapital, Today, 10:10 AM
                            1 response
                            14 views
                            0 likes
                            Last Post NinjaTrader_ShawnB  
                            Started by DiverG20, Today, 10:23 AM
                            0 responses
                            21 views
                            0 likes
                            Last Post DiverG20  
                            Started by SuneSorgenfrei, Today, 09:29 AM
                            0 responses
                            20 views
                            0 likes
                            Last Post SuneSorgenfrei  
                            Started by dodoei, Today, 07:24 AM
                            0 responses
                            14 views
                            0 likes
                            Last Post dodoei
                            by dodoei
                             
                            Started by thecashguys, Today, 06:13 AM
                            0 responses
                            13 views
                            0 likes
                            Last Post thecashguys  
                            Working...
                            X