Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I align the text in a drawTextFixed box?

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

    How can I align the text in a drawTextFixed box?

    With the TextPosition.BottomRight I can align the box to the bottom right.
    But how can I make sure the text within the box is aligned to the right of the box?
    My text has multiple lines, and I would like to line these up.
    I read something about TextAlignment.Right but can't find a way to use this within the statement Draw.TextFixed(this, "text", info, TextPosition.BottomRight, Brushes.Black, ChartControl.Properties.LabelFont, Brushes.Lime, Brushes.Lime, 100);.

    #2
    Hello wjadevries,
    Fixed text is designed for corners / center only, if you want to align within text box then use Draw.Text & you will be able to specify the alignment you need.
    Hope it helps!

    Comment


      #3
      Hello wjadevries,

      Thanks for your post.

      Here is an example:

      TextFixed MyDrawText = Draw.TextFixed(this, "test", "ABCD\nEFGHJKLM\nNOPQRSTUV\nWXYZ", TextPosition.TopRight);
      MyDrawText.Alignment = TextAlignment.Right;


      Reference: https://ninjatrader.com/support/help...?textfixed.htm

      Comment


        #4
        Sounds what I was looking for, but unfortunately it doesn't work.
        I expected multiple lines in a single box to align to the right with your suggestion.
        But the text within the box doesn't change whatever alignment I use.
        No errors in the output panel, but just no effect at all.

        Comment


          #5
          Hello wjadevries,

          Thanks for your reply.

          Please test the example I provided, does the text-align to the right?

          If so, what differences are there between your code and my example?

          Comment


            #6
            As I said, no it doesn't.
            Here's my code (in OnBarUpdate):

            TextFixed myDrawText;
            if (signalPercent>90)
            myDrawText = Draw.TextFixed(this, "WjaIndicatorSpecs", info, TextPosition.BottomLeft, Brushes.Black, ChartControl.Properties.LabelFont, Brushes.Lime, Brushes.Lime, 100);
            else if (signalPercent<-90)
            myDrawText = Draw.TextFixed(this, "WjaIndicatorSpecs", info, TextPosition.BottomLeft, Brushes.White, ChartControl.Properties.LabelFont, Brushes.Red, Brushes.Red, 100);
            else
            myDrawText = Draw.TextFixed(this, "WjaIndicatorSpecs", info, TextPosition.BottomLeft, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Blue, Brushes.White, 100);

            myDrawText.Alignment = TextAlignment.Right; //doesnt work

            Comment


              #7
              Hello Paul,
              Thanks for sharing this valuable information, just wondering if it is possible to Align Fixed Text in Top Center ?

              Comment


                #8
                Hello wjadevries,
                Try : TextFixed myDrawText = Draw.TextFixed(this, .........);

                Comment


                  #9
                  Whats the difference?
                  I declare it upfront and then assign to it in the conditional statement.
                  So I don't know why this should make a difference.

                  However, I tried it and it doesn't work either.
                  Also tried (without result):
                  Draw.TextFixed(this, "WjaIndicatorSpecs", info, TextPosition.BottomLeft, Brushes.White, ChartControl.Properties.LabelFont, Brushes.Red, Brushes.Red, 100).Alignment = TextAlignment.Right;

                  Comment


                    #10
                    Hello wjadevries,

                    Thanks for your reply.

                    Are you saying that you tested the specific example I provided and it did not align to the right?

                    Here is what I see when testing the example I provided

                    Click image for larger version

Name:	wjadevries-1.PNG
Views:	882
Size:	78.7 KB
ID:	1121960

                    Can you confirm that my example does not align right on your system?

                    If my example does align right on your system, then what differences do you see between my example and your code?

                    Comment


                      #11
                      Originally posted by s.kinra View Post
                      Hello Paul,
                      Thanks for sharing this valuable information, just wondering if it is possible to Align Fixed Text in Top Center ?
                      Hello s.kinra,

                      Thanks for your contributions to this thread.

                      There are no means to use Draw.TextFixed to place text in the top center of the chart, only the 4 corners or the center of the chart.

                      Comment


                        #12
                        Oops, my mistake!
                        It DOES work, I was looking at the wrong textbox :-(
                        Thanks a lot!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        574 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        333 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
                        553 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        551 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X