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

Combining Plots and Line values

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

    Combining Plots and Line values

    Hi Guys, I am trying to built my own indicator as per the charting tutorial in the manual and wish to combine plot and line values rather than putting them in twice. For example I have this code with plots as follows. In point 1 I have inserted lines. The problem is I'd like the lines to be the same as the plots without having to duplicate the lines and plot values. For example instead of having to insert a line value manually as per the topline value below I'd like the line to be the minimum value of the extremeup line as per in point 4 below. It would be this, but not sure how to comvert this to drawing a line.

    Plots[0].Min = top;

    At the moment I am manually putting in the lines again at the cutoff points and would like to somehow use the min and max in point 4 below as my lines instead of having to put them in manually. A picture of the indicator is attached and you can see the lines that I am putting in. Any ideas on how to achieve this would be appreciated.

    Thanks
    DJ

    1.
    private double top = 12.0;
    private double midtop = 11.0;
    private double neutralline = 10;
    private double midbottom = 9.0;
    private double bottom = 8.0;
    private int opacity = 150;

    private double topline = 12.0;
    private double midtopline = 11.00;
    private double neutralline = 10.00;
    private double midbottomline = 9.0;
    private double bottomline = 8.0;

    2. Plots

    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "Extremeup"));
    Plots[0].Pen.Width = 3;
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Above"));
    Plots[1].Pen.Width = 3;
    Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "Neutral"));
    Plots[2].Pen.Width = 3;
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Below"));
    Plots[3].Pen.Width = 3;
    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "Extremedown"));
    Plots[4].Pen.Width = 3;

    3. Lines

    Add(new Line(Color.FromKnownColor(KnownColor.Blue), Top, "Topline"));
    Add(new Line(Color.FromKnownColor(KnownColor.White), midtop, "Midtopline"));
    Add(new Line(Color.FromKnownColor(KnownColor.White), neutralline, "Neutralline"));
    Add(new Line(Color.FromKnownColor(KnownColor.White), midbottom, "Midbottomline"));
    Add(new Line(Color.FromKnownColor(KnownColor.Blue), bottom, "Bottomline"));

    4. Setting Limits

    Plots[0].Min = top;
    Plots[1].Max = top;
    Plots[1].Min = midtop;
    Plots[2].Max = midtop;
    Plots[2].Min = midbottom;
    Plots[3].Max = midbottom;
    Plots[3].Min = bottom;
    Plots[4].Max = bottom;
    Attached Files

    #2
    Hello,

    Do the lines you have configured not show up?

    You do not need to specify another set of double values for top and topline. Since these are the same values, you can use the same variable.

    For example when using Add(new Line(Color.FromKnownColor(KnownColor.Blue), bottom, "Bottomline"));

    You should see a line drawn at the bottom value (8.0).

    Does this not work as expected? When you say you have to manually insert your lines, do you mean you have to manually draw the line using the chart object?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Plots issue

      Thanks Matthew sorry if I wasn't clear. Here is a picture of the settings. The lines draw fine. The problem is I have to put everything in twice and not sure why. I just want to have to put in the Misc parameters and want it to draw the lines that separate each sector automatically based on those values rather than have to put in the plot values and then again the line values which are the same as the setting limits in point 4 of my last post. I'm not sure how to combine them.

      For example the line at 12 should be this one:

      Plots[1].Max = top;

      The tutorial/example only covers how to add in lines. In this case my lines and my criteria are exactly the same thing. I'm sure it's simple but not sure how to do it.

      Here are the some other parameters;

      Extremeup.Set(value);
      Above.Set(value);
      Neutral.Set(value);
      Below.Set(value);
      Extremedown.Set(value);
      }

      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Extremeup
      {
      get { return Values[0]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Above
      {
      get { return Values[1]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Neutral
      {
      get { return Values[2]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Below
      {
      get { return Values[3]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Extremedown
      {
      get { return Values[4]; }
      }



      Thanks DJ
      Attached Files
      Last edited by djkiwi; 10-03-2011, 06:08 PM.

      Comment


        #4
        DJ,

        I see - each Plot and Line is going to have it's own property from that indicator dialog box and you cannot combine them. However, you can turn either one off from showing up by setting the correct property in the Initialize() method:

        LinesConfigurable = false;


        PlotsConfigurable = false;


        So with either of these properties configuration turned off, it should clean up the plots/lines you see listed. Then you can just use your Misc section to define the values these lines/plots are set at.
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        3 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Working...
        X