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

Adding Plots

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

    Adding Plots

    I am having a problem adding extra Plot Lines to an existing Indicator.

    I have used the Add method for the lines and also included the extra DataSeries decalartions in Properties.

    What happens is the first 3 Plots (from the original indicator) draw Ok on the chart until I addPlotx.Set(xx); then they disappear and the new Plots dont plot either.

    I have verified that the extra values I wish to Plot are calculating OK by substituting them into the 3 Plots that work

    Is there something else I need to do - or is the a limit on the number of lines that can be plotted on a chart? ( I need 9).

    Thanks for any help or suggestions...





    #2
    imported post

    There is no limits on the number of plots you can have in an indicator. Do you see any errors in the log tab when the plots are not visible? Do these plots completely disappear?
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      Thankyou for the reply.

      Yes there was an error in the log tab which I had missed

      "Error on calling 'OnBarUpdate' method for indicator xxx on bar 0: Index was outside the bounds of the array."

      The error occurs whenever the extra Plots are included - and then the existing lines disappear as well - probably as a result of the error.

      I have tried regeneratinga new wizard script from scratch and it works fine. However whenI add in extra Plot lines ( and update properties accordingly) the new lines do not plot.There is no error in log tab within this new script.

      There must be something very basic I am missing here. When adding new Plot lines, what steps need to be taken beyond

      1. Add(new Plot(Color.Yellow, PlotStyle.Line, "Name"); and

      2. Update Properties with

      [Browsable(
      false)]

      [XmlIgnore]

      public DataSeries Name

      {

      get { return Values[4]; }

      }

      Thanks

      Comment


        #4
        imported post

        Yes, likey something basic. Please look at sample code below. This works.


        ///<summary>



        /// This method is used to configure the indicator and is called once before any bar data is loaded.



        ///</summary>



        protectedoverridevoid Initialize()

        {

        Add(
        new Plot(Color.Orange, PlotStyle.Line, "Plot0"));

        Add(
        new Plot(Color.Green, PlotStyle.Line, "Plot1"));

        Add(
        new Plot(Color.DarkViolet, PlotStyle.Line, "Plot2"));

        Add(
        new Plot(Color.Firebrick, PlotStyle.Line, "Plot3"));

        Add(
        new Plot(Color.AliceBlue, PlotStyle.Line, "Plot4"));

        Add(
        new Plot(Color.Blue, PlotStyle.Line, "Plot5"));

        Add(
        new Plot(Color.Brown, PlotStyle.Line, "Plot6"));

        Add(
        new Plot(Color.Violet, PlotStyle.Line, "Plot7"));

        Add(
        new Plot(Color.Crimson, PlotStyle.Line, "Plot8"));

        Add(
        new Plot(Color.DarkGoldenrod, PlotStyle.Line, "Plot9"));

        Add(
        new Plot(Color.DarkOliveGreen, PlotStyle.Line, "Plot10"));

        CalculateOnBarClose =
        true;

        Overlay =
        true;

        PriceTypeSupported =
        false;

        }

        ///<summary>



        /// Called on each bar update event (incoming tick)



        ///</summary>



        protectedoverridevoid OnBarUpdate()

        {

        Plot0.Set(SMA(
        10)[0]);

        Plot1.Set(SMA(
        15)[0]);

        Plot2.Set(SMA(
        20)[0]);

        Plot3.Set(SMA(
        25)[0]);

        Plot4.Set(SMA(
        30)[0]);

        Plot5.Set(SMA(
        35)[0]);

        Plot6.Set(SMA(
        40)[0]);

        Plot7.Set(SMA(
        45)[0]);

        Plot8.Set(SMA(
        50)[0]);

        Plot9.Set(SMA(
        55)[0]);

        Plot10.Set(SMA(
        60)[0]);

        }

        #region Properties

        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot0

        {

        get { return Values[0]; }

        }

        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot1

        {

        get { return Values[1]; }

        }

        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot2

        {

        get { return Values[2]; }

        }

        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot3

        {

        get { return Values[3]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot4

        {

        get { return Values[4]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot5

        {

        get { return Values[5]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot6

        {

        get { return Values[6]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot7

        {

        get { return Values[7]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot8

        {

        get { return Values[8]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot9

        {

        get { return Values[9]; }

        }



        [Browsable(
        false)]

        [XmlIgnore()]

        public DataSeries Plot10

        {

        get { return Values[10]; }

        }





        #endregion

        RayNinjaTrader Customer Service

        Comment


          #5
          imported post

          Thankyou for posting the code - I was able to adapt it to what I wanted although not without the same initial difficulty.

          Perhaps you could try and reproduce what happened by building any indicator using the wizard which has say3 Plots. Once built try and add 3 more Plots and see if they display properly.

          Thanks again for your help.




          Comment


            #6
            imported post

            Thats exactly what I did exceptI added 6 plots.
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by prdecast, Today, 06:07 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by Christopher_R, Today, 12:29 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by chartchart, 05-19-2021, 04:14 PM
            3 responses
            577 views
            1 like
            Last Post NinjaTrader_Gaby  
            Started by bsbisme, Yesterday, 02:08 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by i019945nj, 12-14-2023, 06:41 AM
            3 responses
            60 views
            0 likes
            Last Post i019945nj  
            Working...
            X