Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

areaOpacity Rectangle not uniform color and wrong opacity output

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

    areaOpacity Rectangle not uniform color and wrong opacity output

    I have the following:

    if (State == State.SetDefaults)
    {
    ...
    ColorRA = Brushes.Cyan;
    ...
    RAOpacity= 30;

    ---

    protected override void OnBarUpdate()
    {
    ...
    Draw.Rectangle(this, "RA"+CurrentBar, false, barsAgo, Highs[0][HighestBar(High, barsAgo)], 0, Lows[0][LowestBar(Low, barsAgo)], Brushes.Transparent, ColorRA, RAOpacity);


    ---

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="RA Region", Description="Color for painted region", Order=0, GroupName="01. Regions Colors")]
    public Brush ColorRA
    { get; set; }

    [Browsable(false)]
    public string ColorRASerialize
    {
    get { return Serialize.BrushToString(ColorRA); }
    set { ColorRA= Serialize.StringToBrush(value); }
    }


    ---

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Rectangle Opacity", Description="Opacity of region", Order=1, GroupName="02. regions Opacities")]
    public int RAOpacity
    { get; set; }


    The output is as this
    Click image for larger version

Name:	rectangle opacity.png
Views:	145
Size:	1.0 KB
ID:	1296299

    What's preventing the correct opacity to display?

    I looked at the documentation and multiple forum threads but no solution found.

    #2
    I also tested with
    [Range(0, 100)]

    does not solve it.

    Comment


      #3
      Hello PaulMohn,

      Thank you for your post.

      What is the result in the NinjaScript Output window if you add a print of the value for RAOpacity?


      This should let you know what value is being used for RAOpacity, and since you have it as a user input you could even test changing the opacity from the indicator settings and seeing if the prints reflect the change.

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

      Comment


        #4
        Originally posted by NinjaTrader_Emily View Post
        Hello PaulMohn,

        Thank you for your post.

        What is the result in the NinjaScript Output window if you add a print of the value for RAOpacity?


        This should let you know what value is being used for RAOpacity, and since you have it as a user input you could even test changing the opacity from the indicator settings and seeing if the prints reflect the change.

        Please let us know if we may be of further assistance.
        Prints output

        RAOpacity 30

        upon editing 70 to 30 value and applying in the indicator properties on the chart.

        Comment


          #5
          What is the solution suggestion you know of?

          Comment


            #6
            Originally posted by PaulMohn View Post
            Prints output

            RAOpacity 30

            upon editing 70 to 30 value and applying in the indicator properties on the chart.
            Based on this information, it seems that you changed it from 70 to 30 and the output value was 30, correct? If that is the case, I do not understand what you are trying to resolve. If you set it to a different value, such as 100, does it print out a value of 100 and have no opacity? Then, if you change it to 0 does it print out and become fully see through?

            I look forward to your clarification.

            Comment


              #7
              Originally posted by NinjaTrader_Emily View Post

              Based on this information, it seems that you changed it from 70 to 30 and the output value was 30, correct? If that is the case, I do not understand what you are trying to resolve. If you set it to a different value, such as 100, does it print out a value of 100 and have no opacity? Then, if you change it to 0 does it print out and become fully see through?

              I look forward to your clarification.
              The documentation states :
              areaOpacity
              Sets the level of transparency for the fill color. Valid values between 0 - 100. (0 = completely transparent, 100 = no opacity)



              When Ctrl+i on the chart the output window prints as 1st print
              State: SetDefaults

              100 value
              Prints: RAOpacity 100
              Click image for larger version

Name:	100.png
Views:	114
Size:	1.3 KB
ID:	1296311

              1 value
              Prints: RAOpacity 1
              Click image for larger version

Name:	1 (2).png
Views:	101
Size:	1.9 KB
ID:	1296312

              0 value
              Prints: RAOpacity 0

              Click image for larger version

Name:	0.png
Views:	98
Size:	1.6 KB
ID:	1296313

              30 value
              Prints: RAOpacity 30
              Click image for larger version

Name:	30.png
Views:	97
Size:	1.9 KB
ID:	1296314

              What is the solution to get the output uniform opacity?

              Comment


                #8
                Originally posted by PaulMohn View Post

                The documentation states :
                areaOpacity
                Sets the level of transparency for the fill color. Valid values between 0 - 100. (0 = completely transparent, 100 = no opacity)



                When Ctrl+i on the chart the output window prints as 1st print
                State: SetDefaults

                100 value
                Prints: RAOpacity 100
                Click image for larger version

Name:	100.png
Views:	114
Size:	1.3 KB
ID:	1296311

                1 value
                Prints: RAOpacity 1
                Click image for larger version

Name:	1 (2).png
Views:	101
Size:	1.9 KB
ID:	1296312

                0 value
                Prints: RAOpacity 0

                Click image for larger version

Name:	0.png
Views:	98
Size:	1.6 KB
ID:	1296313

                30 value
                Prints: RAOpacity 30
                Click image for larger version

Name:	30.png
Views:	97
Size:	1.9 KB
ID:	1296314

                What is the solution to get the output uniform opacity?
                Thank you for your reply.

                Since you are using the tag "RA"+CurrentBar I suspect that what you are seeing is multiple rectangles being drawn with different opacities; is your desired behavior to draw only one rectangle? If so, you should use one tag only and that way the draw object will be modified each time Draw.Rectangle() is called with that same tag. Otherwise, each time you call your logic with "RA"+CurrentBar then a new rectangle is drawn.

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

                Comment


                  #9
                  Originally posted by NinjaTrader_Emily View Post

                  Thank you for your reply.

                  Since you are using the tag "RA"+CurrentBar I suspect that what you are seeing is multiple rectangles being drawn with different opacities; is your desired behavior to draw only one rectangle? If so, you should use one tag only and that way the draw object will be modified each time Draw.Rectangle() is called with that same tag. Otherwise, each time you call your logic with "RA"+CurrentBar then a new rectangle is drawn.

                  Please let us know if we may be of further assistance.
                  That was the solving suggestion. Good elucidation. Thank you.

                  Draw.Rectangle(this, "RA", false, barsAgo, Highs[0][HighestBar(High, barsAgo)], 0, Lows[0][LowestBar(Low, barsAgo)], Brushes.Transparent, ColorRA, RAOpacity);

                  The +CurrentBar was drawing a new rectangle on each new bar within the rectangle region bounds.

                  Comment

                  Latest Posts

                  Collapse

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