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

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:	42
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.
      Emily C.NinjaTrader Customer Service

      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.
            Emily C.NinjaTrader Customer Service

            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:	25
Size:	1.3 KB
ID:	1296311

              1 value
              Prints: RAOpacity 1
              Click image for larger version

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

              0 value
              Prints: RAOpacity 0

              Click image for larger version

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

              30 value
              Prints: RAOpacity 30
              Click image for larger version

Name:	30.png
Views:	18
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:	25
Size:	1.3 KB
ID:	1296311

                1 value
                Prints: RAOpacity 1
                Click image for larger version

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

                0 value
                Prints: RAOpacity 0

                Click image for larger version

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

                30 value
                Prints: RAOpacity 30
                Click image for larger version

Name:	30.png
Views:	18
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.
                Emily C.NinjaTrader Customer Service

                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 futtrader, 04-21-2024, 01:50 AM
                  5 responses
                  56 views
                  0 likes
                  Last Post NinjaTrader_Eduardo  
                  Started by PeakTry, Today, 10:49 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post PeakTry
                  by PeakTry
                   
                  Started by llanqui, Today, 10:32 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post llanqui
                  by llanqui
                   
                  Started by StockTrader88, 03-06-2021, 08:58 AM
                  45 responses
                  3,992 views
                  3 likes
                  Last Post johntraderuser2  
                  Started by TAJTrades, Today, 09:46 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post TAJTrades  
                  Working...
                  X