Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Brush Style erases after saving transparent brush

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

    Brush Style erases after saving transparent brush

    I AddPlot in State.SetDefaults, using this code, nothing fancy:

    Code:
    AddPlot(Brushes.DeepPink, "BBBUpper");
    However, in State.Configure, I have such code:

    Code:
    if (! BandsBool)
    {
    AddPlot(Brushes.Transparent, "BBBUpper");
    }
    So when I untick box of BandsBool, this code "removes" this plot from the chart. However, if I want to bring it back in, that is tick box of BandsBool (making it TRUE again), it doesn't bring the plot back and leaves it transparent.

    Solution? I want to be able to both hide/show plot and keep the default formatting, not transparent.

    #2
    Hello UltraNIX,

    Thank you for your note.

    I'm assuming the BandsBool is a bool user input, is that correct? I'm seeing that this works when I switch the user input to unchecked and then checked again:

    else if (State == State.Configure)
    {
    if (BandsBool)
    {
    AddPlot(Brushes.DeepPink, "BBBUpper");
    }
    else
    {
    AddPlot(Brushes.Transparent, "BBBUpper");
    }
    }

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Yes, but this approach comes with the price - user cannot edit plot style, change color, width, etc. Can I have ability to change style and still have option to toggle between showing plot and not?

      Comment


        #4
        Hello UltraNIX,

        Thank you for your reply.

        If your indicator or strategy dynamically adds plots during State.Configure, the user will unfortunately not have an opportunity to select the plot or to set the plot configuration via the UI.

        As a workaround, you may use custom public Brush, Stroke, or PlotStyle properties which are accessible in State.SetDefaults and pass those values to AddPlot() during State.Configure.

        An example may be found near the end of this page:



        Please let us know if we may be of further asssistance ot you.

        Comment


          #5
          I am able to "bring back" plots after unchecking "show plot" (custom Bool) and clicking OK and closing indicators window.

          I have one more question. Let's say user adjusts plot style (changes color, width) - how can I save that into a variable, so if he decides to hide plots and then show them again, it would show HIS VERSION of plots, because as for now, it just shows default plot.

          I will provide my code snippets of where I set plots:

          Class section:
          Code:
          private Stroke iStroke = new Stroke(Brushes.Chartreuse, 2);
          private string Plot1s = "+-VolCount";
          private Brush tBrush = Brushes.Transparent;
          State == State.SetDefaults:
          Code:
          AddPlot(iStroke, PlotStyle.Bar, Plot1s);
          State == State.Configure:
          Code:
          if (PlotBool)
          {
          AddPlot(iStroke, PlotStyle.Bar, Plot1s);
          }
          else
          {
          AddPlot(tBrush, Plot1s);
          }
          So where and how should I update iStroke value with the plot style that user saved?

          Comment


            #6
            Hello UltraNIX,

            Thank you for your reply.

            It looks like you aren't setting the stroke as a user input, nor are you adding the plot dynamically in State.Configure only. I'm attaching a simple example script that allows the user to input the stroke values and the plot style, then applies these to a plot set up in State.Configure so it can be dynamically set and you can toggle transparency on and off.

            Please let us know if we may be of further assistance to you.
            Attached Files

            Comment


              #7
              Thanks, NinjaTrader_Kate , it works for plots (Stroke & Brush). However, for Lines, it doesn't.

              I attach the screenshot, as you can see, there are 2 separate rows:
              Lower Line Brush [DarkOliveGreen]
              Lower [transparent color], Solid, 1 px, 20

              what I would want - have one line that does not become transparent color, when I untick Show Lines? checkbox.

              Code:
              Class section:
              Code:
               private const string Line1s = "Lower";
              State == State.SetDefaults:
              Code:
              bLine1  = Brushes.White;
              AddLine(bLine1, 20, Line1s);
              State == State.Configure:
              Code:
               if (LinesBool)
              {
              AddLine(bLine1, 20, Line1s);
              AddLine(lBrush, 80, Line2s);
              }
              else
              {
              AddLine(tBrush, 20, Line1s);
              AddLine(tBrush, 80, Line2s);
              }
              P.S. I haven't added another line for 2nd line. I want to solve 1st line first, then adapt the solution for the 2nd line.

              Attached Files

              Comment


                #8
                I'd like to add, that colors only update if I close Indicators panel. I would want it to update after I check/uncheck checkbox.

                I tried adding ForceRefresh(); in State.Configure and [RefreshProperties(RefreshProperties.All)] before Properties, yet nothing does the trick :/

                Comment


                  #9
                  Okay, I removed AddLine(); from State.SetDefaults and it removed those 2 transparent color rows from Indicator Panel. Now it works as expected.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  637 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  366 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  107 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  569 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  571 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X