Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

To solve a riddle about brushes

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

    To solve a riddle about brushes

    I mostly have my indicator all set up in strategy builder, the saved and unlocked version. I want to make the colors interchangeable by end user, for the various items.

    First, can I do this in the builder? Then view the script. For instance, Draw.Rectangle, what brush type do I use for that? It's not BarBrush. I know there's Mybrush. (?)

    I took my InsideOutside Bar Indicator & copied paste the three components for coloring bars and laid them in my script (Just for a starting point) got it to compile and it actually works, it colors the bars as the brush name indicates. I want to be able to change the colors for the rectangles in the interface (Think thats what you call it)

    The screenshot are the three components but I piled them on top of each other just for an easy reference (I know they don't go like that) I just need to have the correct brush name for the rectangles. And any suggestions without of course violating any rules for actually helping us lol give me some riddles to figure out lol I'm non C# script literate.


    Click image for larger version

Name:	2024-11-06 20_08_54-2024_11_06_20_07_55_NinjaScript_Editor_Strategy_SupportResistanceUnlocked.png - .png
Views:	68
Size:	38.2 KB
ID:	1323884

    #2
    Hello trdninstyle,

    Thank you for your post.

    You're on the right track, you can create a brush input for the user to select and provide that brush to your Draw.Rectangle call.

    We have a Help Guide page on creating user defined color inputs below which has code snippets:



    This can also be done from the Strategy Builder, you can create a Brush input within the Inputs and Variables screen.

    Please let us know if you have any further questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      How do I apply, not BarBrush, but SomethingBrush to Draw.Rectangle call?

      So, of those three items in the screenshot, I keep 2 of the 3 the same except for BarBrush ? Replace the "Bar" with another word indicating the Draw.Rectangle?


      BarBrush = BorderBrush;

      Comment


        #4
        I'll start trying this is the builder until I get it right and then view the script. I may have to ask a few questions as I go thru that process in the builder.

        Comment


          #5
          BarBrush paints the bar. It is not going to paint the rectangle you are drawing.



          You should be supplying 'BorderBrush' as your brush within your Draw.Rectangle call.
          Gaby V.NinjaTrader Customer Service

          Comment


            #6
            Thanks, I know not Bar, so it's BorderBrush as my brush within my Draw.Rectangle call.

            When you say 'within' are you referring to this; ?

            {
            Draw.Rectangle(this, @"SupportResistance Rectangle_1 " + Convert.ToString(CurrentBars[0]), false, 3, High[3], 1, Low[1], Brushes.Transparent, Brushes.LimeGreen, 20);
            }

            ...,BorderBrushes,20); in place of, Brushes.LimeGreen,20);

            Or and maybe both;

            {
            BorderBrush = Brush; in place of, BarBrush = BorderBrush
            }

            Comment


              #7
              Hello trdinstyle,

              There is no need to reassign BorderBrush a value, it is already defined in State.DataLoaded.

              You simply need to supply it as the Brush parameter for your Draw.Rectangle call. You can supply it for the brush argument or the areaBrush argument, or both. It depends on how you want the rectangle to be colored.

              Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, Brush areaBrush, int areaOpacity)

              Gaby V.NinjaTrader Customer Service

              Comment


                #8
                Thanks,

                "There is no need to reassign BorderBrush a value, it is already defined in State.DataLoaded."

                The value here is this, I think?

                {
                BorderBrush = Brush .. Yes, the value is this item, I'm certain.
                }
                ********************

                Is this the actual wording within my draw call? Brush brush, Brush areaBrush, (For the two items to be brushed, outline and area)

                For instance for the word bool, I don't literally type bool but true or false. Also for instance, I don't literally type in the word IsGlobal, I type in false, "AutoFib".

                Or I do literally type Brush brush and Brush areaBrush.

                Comment


                  #9
                  This code isn't necessary and is redundant. BorderBrush is already defined in State.DataLoaded.

                  Code:
                  {
                  BorderBrush = Brush.. Yes, the value is this item, I'm certain.
                  }

                  Correct, you aren't meant to literally type in these in your Draw.Rectangle call.

                  Brush is a type and areaBrush is what the parameter is called (simply just to describe what this parameter is). You aren't going to literally type Brush areaBrush, you are going to supply BorderBrush as the parameter. BorderBrush is a Brush that you want to use for the Rectangle's area.

                  For example, bool isGlobal - the type of the parameter is a bool, and the parameter is called isGlobal. You would supply a true or false value, not type in 'bool' or 'isGlobal'. ​
                  Gaby V.NinjaTrader Customer Service

                  Comment


                    #10
                    Okay. I'm finally coming along, I'm understanding. Is everything in this screenshot on par?


                    Click image for larger version  Name:	2024-11-07 12_58_33-2024_11_07_12_53_06_Chart_5m_RTH.png.png Views:	0 Size:	38.6 KB ID:	1323957

                    And everything in the properties should be all set, except for changing the name from DownBars to something more appropriate that fits.


                    [XmlIgnore()]
                    [Display(Name = "DownBars", GroupName = "NinjaScriptParameters", Order = 0)]
                    public Brush BorderBrush
                    { get; set; }

                    // Serialize our Color object
                    [Browsable(false)]
                    public string BorderBrushSerialize
                    {
                    get { return Serialize.BrushToString(BorderBrush); }
                    set { BorderBrush = Serialize.StringToBrush(value); }
                    }

                    Comment


                      #11
                      The code looks fine to me, as far as properly supplying the brush arguments to the Draw method.
                      Gaby V.NinjaTrader Customer Service

                      Comment


                        #12
                        Hey it works lol

                        I wanted to make the outline to be transparent and just the area to color, I tried putting back Brushes.Transparent for that but it wouldn't allow me.

                        I didn't want to take up additional space in the interface and make that a choice, whether to color that outer line of the rectangle, just have the code perform that.
                        How would I handle this? To have that outline to be transparent.

                        This is awesome tho, I can do this.
                        Attached Files

                        Comment


                          #13
                          You would need to set the brush parameter (not areaBrush) to Brushes.Transparent.
                          Gaby V.NinjaTrader Customer Service

                          Comment


                            #14
                            Yes, that worked. The first time I did it I placed it in the wrong one. Thankyou very much.
                            When I do the opposite side I'll just put IBorderBrush, unique name.

                            Have a good day the rest of the way out. Thank you again.

                            Comment


                              #15
                              Minor thing, I would like to switch the GapUp on top of the GapDown.

                              I understand how to switch around the other items in the Parameters, by changing the order numbers how I want them to display. I switched them to match for now.
                              I appreciate Ninja's service.

                              Click image for larger version

Name:	2024-11-07 20_53_45-2024_11_07_20_49_47_Strategies.png - Paint.png
Views:	31
Size:	14.3 KB
ID:	1323976

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Nancy75, Today, 10:22 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by Armin, Today, 02:26 AM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by xiinteractive, 08-08-2023, 11:55 AM
                              44 responses
                              887 views
                              3 likes
                              Last Post bltdavid  
                              Started by Thomas75k, 11-29-2024, 02:11 AM
                              7 responses
                              76 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by nelslynn, Today, 09:34 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X