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

updated opacity from drawtextfixed doesnt change

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

    updated opacity from drawtextfixed doesnt change

    I update the text and opacity for an earlier placed (thus existing) text from within the onBarUpdate method in my indicator.
    However, the text updates fine, but the opacity is changed (as you can see in the properties window) but the text doesn't show as semi-transparant in the chart.
    I also tried a Remove followed by a Draw.TextFixed with the new opacity, but that doesn't make any difference.

    PS: also tried Invalidate and ForceRefresh without effect.

    Click image for larger version

Name:	updated drawtext opacity doesnt change.png
Views:	302
Size:	125.2 KB
ID:	1123701

    #2
    Hello wjadevries,
    It seems you're trying to change opacity from drawing objects, if you need to change opacity then you should do this from indicator settings or every time indicator will override the change you do from drawing objects. You can set a variable for opacity & then use it in fixed text command, this variable should be available in indicator settings, so you can change it from there.
    Hope it helps!

    Comment


      #3
      I'm not changing it from drawing objects, I just included the drawing objects property window to show you it's on opacity 70%.
      This value has been set from within the indicator with the Draw.TextFixed opacity.
      But as you can see on the chart the green box isn't transparant, it's 100% opaque.
      If I change it manually in the properties window and save it works of course, but that's not the issue.
      Changes in opacity from within the indicator with TextFixed don't work; that's the issue.

      Comment


        #4
        Can you share the snippet code of fixed text, for me its working fine, I can control opacity from within the indicator code.
        Code:
        Draw.TextFixed(this, "test", "Test text", TextPosition.TopLeft, Brushes.White, label_font, null, Brushes.Green, 70);
        Last edited by s.kinra; 10-21-2020, 12:53 AM. Reason: added sample code

        Comment


          #5
          Here's the snippet.
          Sorry for the lack of indentation; thats unfortunately removed by your forum editor upon pasting.

          Code:
          protected override void OnBarUpdate()
          {
          if (CountDownMessages) {
          if (RemoveMessages && lastCount<-2) {
          //really remove
          RemoveDrawObject("WjaChartMessage");
          lastIndicator = null;
          } else {
          //redraw a few times with lower opacity before removal
          lastCount--;
          int opacity = RemoveMessages ? 100+lastCount*25 : 70;
          Draw.TextFixed(this, "WjaChartMessage", lastCount + " " + lastMessage, TextPosition.Center, Brushes.White, MessageFont, lastBrush, lastBrush, opacity);
          
          //doesnt help:
          // ChartControl.InvalidateVisual();
          // ForceRefresh();
          }
          }
          }

          Comment


            #6
            Hello,
            Your code is correct, so I had a closer look on the snapshot, just check once with lower opacity to see the diff, I am attaching your snapshot with markings, marked in black seems to be lighter than that marked in blue & I feel in both cases you're using LimeGreen color.
            Click image for larger version

Name:	Screenshot 2020-10-21 141700.jpg
Views:	398
Size:	157.0 KB
ID:	1123766

            Comment


              #7
              No, it really doesn't work.
              The indicator lowers the opacity in steps and none of it is visible on screen, even though every step (playback mode) shows the correct value in the drawing properties window.

              And don't look at the two on the left, I'm talking about the chart centered text only.

              Comment


                #8
                I am just asking you to do a comparison by changing the opacity in your code, so you get the clarity if its changing or not. Best is to keep a very low opacity (for example 20) so you actually can figure out easily what the diff is & if its working or not. Opacity is not transparency so don't expect the same behavior. I am sure its working, you give a try by manually changing it.
                FixTextTest.zip
                Here you get a test sample, you can change opacity & see the diff.

                Comment


                  #9
                  I already did that.
                  as mentioned the indicator lowers up to 30% in steps.
                  All steps look equal (opaque) on screen.
                  If I change it manually it becomes transparant.

                  to be even more specific; if I set the opacity with the indicator initially to 30% its fine on screen, just the subsequent changes don't work.

                  Comment


                    #10
                    Correction:
                    If I START with 100% in the indicator, lowering doesnt show it on screen.
                    But if I start with 89% it does work, 90% or higher doesn't...

                    Comment


                      #11
                      Can you modify this, it should not accept more then 100 opacity.
                      int opacity = RemoveMessages ? 100-lastCount*25 : 70;
                      For me it works even with opacity 4, possibly some graphics issue for you.

                      Comment


                        #12
                        Oke, this seems to be a bug, please check and report.
                        I'll just start with 89% to solve it.

                        Comment


                          #13
                          If you look at the code you'll see that the counter is decremented.
                          So the opacity is lowered.

                          ps: lastcount starts at 0.

                          Comment


                            #14
                            Oh ok, I noticed it but declaration was not avl, so I suggested it.

                            Comment


                              #15
                              Have you tried it yourself starting from above 90% and from 89% or lower?
                              This seems to be the threshold, when starting above 90% subsequent lowering doesn't show up on screen although you can see the value in the drawing object properties.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by TradeForge, Today, 02:09 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post TradeForge  
                              Started by Waxavi, Today, 02:00 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by elirion, Today, 01:36 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post elirion
                              by elirion
                               
                              Started by gentlebenthebear, Today, 01:30 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post gentlebenthebear  
                              Working...
                              X