Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ColorSeries in NT8

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

    ColorSeries in NT8

    Sorry for the basic question,
    in NT7 I used to write
    [XmlIgnore] [Browsable(false)]
    private ColorSeries Hist_Plot_Colors { get { return base.PlotColors[4]; } }
    then I would access it by writing:
    Hist_Plot_Colors[0] = Color.Blue.

    In NT8 I write
    PlotBrushes[4][0] = Color.Blue;
    but I like to write the code as
    Hist_Plot_Colors[0] = Brushes.Blue.

    what is the equivalent in NT8 of
    private ColorSeries Hist_Plot_Colors { get { return base.PlotColors[4]; } }
    ?
    Thank you
    G
    Last edited by giogio1; 05-08-2022, 05:46 PM.

    #2
    Hello G,

    ColorSeries was not documented for NinjaTrader 7, so I would not know an equivalent for NinjaTrader 8.

    But you want a public color (brush) selector property, you can add this. Below is a link to the help guide.


    If you want to set a plot brush this is set with the PlotBrushes collection.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.
      Not that important but does that forces me to write an improper code?
      What I mean is the following.
      The help example writes:
      public Series<double> Upper
      {
      get { return Values[0]; }
      }

      So I can give a name to the Values[0] which gives me flexibility if I want to add a plot change the numbers in just one point.

      But I cannot to that for the associated color. The example in the help does not provide a solution.
      Do you have a suggestion?
      If not don't worry too much, I consider this good coding practice but not absolutely necessary.
      Best
      G

      Comment


        #4
        Hello G,

        That would return a Series<double>, which is documented code. ColorSeries was not documented.

        However, I don't understand what you mean by associated color? Associated with what?

        Are you talking about the PlotBrushes for the colors on each bar of a plot?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your reply and the effort to understand where I was not clear.

          Yes I meant the PlotBrushes for the colors on each bar of a plot, ultimately I want to name that series.

          in other words:

          I am able to write
          [Browsable(false)] [XmlIgnore]
          public Series<double> Rsi { get { return base.Values[0]; } }
          so in the OnBarUpdate function I can write
          Rsi[0] = RsiVal;
          instead of an ugly
          Value[4][0] = RsiVal;

          I'd like to do the same for its color
          i.e. to be able to write something like:
          [Browsable(false)] [XmlIgnore]
          public Series<Brushes> RsiBrushes { get { return base.PlotBrushes[4]; } } // doesn't compile but it may give the idea.

          so that in the OnBarUpdate() section I can write
          RsiBrushes[0] = isUp ? Brushes.Blue : Brushes.Red;
          instead of an ugly
          PlotBrushes[4][0] = isUp ? Brushes.Blue : Brushes.Red;

          How can I correct the line that does not compile?
          Thank you
          G

          Comment


            #6
            Hello G,

            PlotBrushes already exists and is public and can accessed from a host script. There is no need to make a duplicate variable that points to the same object when one already exists.

            Print(MyIndicatorName().PlotBrushes[0]);

            Can you clarify what you are trying to acheive?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I think this is what he is thinking. We can assign a name to say, Plot #1 (Values[1] = MySecondPlot) so we don't have to change code when we switch around the order of plots. Nice, but we still need to go through code to change the plot number in every instance of PlotBrushes[1]. It could be automated if each PlotBrush had an optional name also. If Values[1][0] = could be MySecondPlot[0] = , maybe PlotBrushes[1][0] = could be something like MySecondPlotColoring[0] = , or whatever we would name it. It would be a convenience.

              Something like this:

              [Browsable(false)]
              [XmlIgnore()]
              public Series<double> MySecondPlot
              {
              get { return Values[1]; }
              }

              [Browsable(false)]
              [XmlIgnore()]
              public PlotBrush MySecondPlotColoring
              {
              get { return PlotBrushes[1]; }
              }

              Maybe even something like MySecondPlot.PlotBrush[0] = ......
              Last edited by eDanny; 05-10-2022, 11:12 AM.
              eDanny
              NinjaTrader Ecosystem Vendor - Integrity Traders

              Comment


                #8
                Hello eDanny,

                PlotBrushes is a collection of plots called a BrushSeries.. it's not a data series (meaning its not a Series<double> and is not a Series<Brush>).

                But making this a public variable property isn't documented or supported.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  My examples are not anything except something to explain the idea the OP is trying to make. Basically, a way to use a name assigned to PlotBrushes for a specific Plot instead of the more cumbersome PlotBrushes [x][x].
                  eDanny
                  NinjaTrader Ecosystem Vendor - Integrity Traders

                  Comment


                    #10
                    Hello eDanny,

                    It's not documented, but something private like:

                    Class:
                    private BrushSeries myBrushes;

                    DataLoaded:
                    myBrushes = PlotBrushes[0];

                    OnBarUpdate:
                    Print(myBrushes[0].ToString());


                    might work.. not tested.. just following the general sense of how C# works.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      It works beautifully!
                      Thank you also eDanny for interpreting my poor english.
                      Now I can change the order of the plots without reworking the code.
                      G

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      647 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X