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

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.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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
            Kate W.NinjaTrader Customer Service

            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 Taddypole, 04-26-2024, 02:47 PM
                  6 responses
                  67 views
                  0 likes
                  Last Post NinjaTrader_PatrickH  
                  Started by ttrader23, Yesterday, 09:04 AM
                  5 responses
                  26 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by KonAdams, 05-07-2024, 10:53 PM
                  10 responses
                  27 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by kevinenergy, 02-17-2023, 12:42 PM
                  119 responses
                  2,839 views
                  1 like
                  Last Post DTSSTS
                  by DTSSTS
                   
                  Started by reynoldsn, Today, 07:23 AM
                  2 responses
                  7 views
                  1 like
                  Last Post reynoldsn  
                  Working...
                  X