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

Dynamic number of plots and lines

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

    Dynamic number of plots and lines

    My understanding is that all plots and lines need to be set in Initialize(), will show up in the configuration dialog and in the Data Box. They are fixed, immutable.

    Is there any way around this? For example, to do a ribbon indicator, one would want to let the user specify how many moving averages to use, there is no need to configure the plots individually, and you may not want all of them showing up in the Data Box.

    I know that the indicator could create a large number (20, 50, whatever), the user could specify a number of plots to use and the indicator could set any unwanted ones transparent. This seems wasteful and having the unused ones show up in the configuration dialog initially and the Data Box at run time is not reasonable.

    How do I work around this? Is there really no way to just have one plot in the configuration and then have the indicator create as many more plots as needed in OnStartUp()? If the only way is to create a large number to begin with, then what about at least deleting the unwanted ones in OnStartUp() so they do not show up in the Data Box?

    --EV

    #2
    Hello,

    No way to work around this unfortunately.

    Let me know if I can be of further assistance.

    Comment


      #3
      If the indicator has to use the create too many, color unused ones transparent, is there any way to suppress them showing up in the configuration dialog and/or in the Data Box?

      --EV

      Comment


        #4
        Hello,

        No Unfortunaley not, this is not supported.

        All plots will show on the chart, databox and properties. You must define a plot in Initialize().

        Let me know if I can be of further assistance.

        Comment


          #5
          OK -- got it -- thanks.

          Something for you folks to think about -- if one wanted to implement a moving average ribbon indicator for NT, how would one do it (aside from overriding Plot()).

          No need to answer me ... just food for thought.

          --EV

          Comment


            #6
            Hello,

            You would have to specify how many MA's you wanted to displace and then code them in as plots.

            Let me know if I can be of further assistance.

            Comment


              #7
              Dynamic number of plots and ribbon average - see attached.

              Well, this thread is inactive more than 2 years, but I found a solution.
              There is no problem to create requested nr of plots in Initialize() , without hardcoding, and Add(new Plot(... can receive any computed arguments.
              My workaround to overcome a problem of only default input values available during Initialize() is to read them from external file. This solution has its limitation - you should edit the input file in external editor everytime before you need to change input values, and you cannot change file path the input values are read from. I can live with it, i'm not sure if others can.
              An alternative could be to create custom form for supplying input values during Initialize() , I prefer not to do it, as I feel it may interfere with the framework.

              May be, polymorphism mechanism used in OnStartUp() is worth attention either. It saves a lot of hardcoding.

              I'm attaching example input file.
              Order of parameters is: Average type, low average,high average , step , opacity , saturation, luminosity.

              Please pay attention that the only known average types in my code are: SMA,EMA,WMA and HMA. Of course, it's possible to add other indicators, in the switch statement in OnStartUp() . On default, nothing is done and you'll see an empty indicator. I didn't implement an exception, as framework has an exception of its own.

              The last 3 parameters are not relevant for RMMA, They allow to play with rainbow blends.

              I'm using 256 bars dataseries, therefore there is a limit to high average is : < 254.

              Eventually, credits should be given to a person, who created original RMMA.

              Attachments: a code, input file and 2 screenshots
              Attached Files

              Comment


                #8
                I'm working on a similar indicator. In the initialize I have created a loop to create the plots the user specifics dynamically, issue is not how do I assign values to each Plot?

                protectedoverridevoid Initialize()
                {
                int c=0;
                do
                {
                Add(
                new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.HLine, "Line" + c));
                c++;
                }
                while(c <= drawlines);

                Overlay = true;
                PlotsConfigurable =
                false;
                }

                Setting the Pen to each plot is not an issue. The names are in accordance to the initialize, so Line + c, Line 1, Line2 etc.

                Plots[i].Pen = new Pen(Color.Blue);
                Print(
                "Setting " + Plots[i].Name + " Color " + Plots[i].Pen.Color + " Value " + Plots.GetValue(i,0));

                Can't figure out how to set the value, I'm sure it's easy, the Plot class has MIN & MAX, but this doesn't draw anything.


                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by alifarahani, Today, 09:40 AM
                6 responses
                31 views
                0 likes
                Last Post alifarahani  
                Started by Waxavi, Today, 02:10 AM
                1 response
                17 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by Kaledus, Today, 01:29 PM
                5 responses
                14 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Waxavi, Today, 02:00 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by gentlebenthebear, Today, 01:30 AM
                3 responses
                17 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X