Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Scaling Plots on a New Panel

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

    Scaling Plots on a New Panel

    Hi,

    I would like to know if you can advise a way that I can better scale my plot on a new panel. My indicator, which is plotted in a new panel, is just a set of horizontal lines (constant Y value) on which the colour changes each bar. The problem I having is that the line that has the lowest Y value is the very bottom of the new panel and I would like some space under it to make it more visible. For example, if my lowest Y value is 1, I would like the scale to extend down to 0, so that there is visible space under the lowest value.

    The other problem I'm seeing is that in order to make my indicator easily visible I have set the thickness of the plot line to anywhere between 4 and 8. This seems to have the effect of increasing the space between each plot line. If I squash the size of the panel then the space between the lines is reduced but the thickness of the lines is also reduced. In addition to that the thickness of the bottom line is reduced more than the thickness of the lines above it.

    One thing I did try to create space under the lowest line is to set the left most value of the plot of the lowest line to zero, and all the other values to 1, but as soon as the zero value disappears off the left of the chart the auto scaling shifts the whole plot down again. One hack I thought of would be to add a dummy plot at the lowest level and set its colour to transparent. if this is the only solution is it then possible to stop this plot appearing in the parameter list?

    If there is more control over the scale that would be a better solution.

    Thanks,
    Will.

    #2
    Hello Will,

    Thank you for your post.

    The indicator is autoscaling to the highest and lowest objects. So we would add a zero line to offset the lowest point, but make the color transparent:
    Code:
    Add(new Line(Color.FromKnownColor(KnownColor.Transparent), 0, "Zero"));
    Your other choice is to draw a horizontal line at 0 that is colored transparent:
    Code:
    DrawHorizontalLine("Zero", 0, Color.Transparent)

    Comment


      #3
      Hi, thanks that makes sense, however seems not to be working. I have tried both those suggestions and the lines do not seem to plot on the panel. I changed to a visible color but it made no difference.

      Will.

      Comment


        #4
        Hello Will,

        Thank you for your response.

        Please set AutoScale to True and DrawOnPricePanel to False.
        Code:
        protected override void Initialize()
        {
            AutoScale = true;
            DrawOnPricePanel = false;

        Comment


          #5
          Hi, I still cant get the Add() suggestion to work, but I was able to get it to work with

          Drawline('zero", true, ...);

          so that autoscale was true.

          Comment


            #6
            Thanks,

            I did have drawonpricepanel set as you said, but not Autoscale, it was set to true in the parameters. One thing I did notice on my indicator parameters is that at certain times autoscale is set to true in the parameter list and is greyed out, so that I cant change it. Do you know what conditions would cause this to occur?

            Will.

            Comment


              #7
              I dont seem to have this operating consistently. I've loaded the indictor into another computer, and I'm using the add line method, but the line does not appear.

              I have set autoscale to true, and the line exists in my input parameters at the correct value.

              Anything else I should look for?

              ta,
              Will.

              Comment


                #8
                Will, would you get a more consistent outcome with using a plot then directy?

                i.e.

                protected override void Initialize()
                {
                Add(new Plot(Color.Green, "Zero0"));
                }

                protected override void OnBarUpdate()
                {
                Value.Set(0);
                }
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  I had thought of that, but would I be able to remove the settings for that plot from the input parameters? ie, that plot doesnt appear in the input parameter settings.

                  Will.

                  Comment


                    #10
                    That would not be possible on a per plot basis, but perhaps use PlotsConfigurable == false and then make custom properties as desired for the other values?
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      ok, I could try that. Since I have already created my indicator and added 4 plots to it using the new indicator wizard, i would something more like zero.Set(), rather than Value.Set(), I already tried that and it didnt work.

                      Is there a way to add the necessary data series and other components that would normally be added by the wizard, so that my new plot is named correctly?

                      Comment


                        #12
                        You could go just by this template.

                        Alternatively, create a new indicator from the wizard and just copy over your property / plot definition then for ease of use.
                        Attached Files
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          I see, so just create a new indicator temporarily, copy the code from it and insert into my first indicator.

                          I can try that.

                          Interestingly, I was playing around again with the first solutions suggested by Patrick, because I wanted to work out why that plotting method was working, and now it isnt. I decided to remove the Add Line() method and just go back to the plot at zero method. suddenly my Add line() has appeared on the chart, but i have taken the code for Add Line() out of the indicator!

                          thats a bit strange...

                          anyway, I think i can put together something that will work from all these suggestions.

                          Thanks,
                          Will.

                          Comment


                            #14
                            Correct Will, that's the idea. Or pick some property setups from the system indicators and change to your needs. Yes that outcome sounds definitely unexpected to me as well. If you see anything you would need further assistance on then please just post again.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Hi,

                              I think I have an idea about what is going on with the Add(new Line("zero")) sometimes working and sometimes not.

                              I put the Add Line() in the Initialize() method, because I think thats the only place it can go? I get runtime errors if I call it from OBU.

                              I think what is happening is that the line is being added to the price panel before I am able to set the indicator to display on a new panel.

                              So I then added the required code

                              Overlay = false;
                              DrawOnPricePanel=false;
                              AutoScale=true;

                              and now I am back to the same problem where the line is apparently added, and can be seen now in my parameters list, but does not show in the new panel plot.

                              so I then add in OBU to draw another line

                              DrawLine("zz", true, 10, 0, -2, 2, Color.Transparent, DashStyle.Solid, 1);

                              and without changing anything else the line added by Add(line()) suddenly appears, and also gives me space above and below. This combination seems to do the trick, but it does seem like a real and unnecessary hack.

                              Will.
                              Last edited by dontpanic; 03-17-2014, 08:42 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by benmarkal, Yesterday, 12:52 PM
                              3 responses
                              23 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by helpwanted, Today, 03:06 AM
                              1 response
                              19 views
                              0 likes
                              Last Post sarafuenonly123  
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              11 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              244 views
                              0 likes
                              Last Post Nyman
                              by Nyman
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              9 responses
                              388 views
                              1 like
                              Last Post Gavini
                              by Gavini
                               
                              Working...
                              X