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

DrawTextFixed

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

    DrawTextFixed

    Hi,

    This is a very useful addition in 6.5. Is it possible to add some X and Y offset capabilities to TextPosition so the text location can be moved away from the standard textPosition(s). (Could use DrawText of course but it doesnt hold a fixed location).

    At present the .BottomRight overprints some of the standard NT indicators such as Bar Timer.

    Also a question - is there a way to determine where Close[0] is in relation to the Y current scale (to allow for script controlled toggling of .textPosition to avoid price bars overprinting drawn text).

    Thanks

    #2
    Check out this reference sample. I use the technique of using line breaks to move them up from the fixed positions.

    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh,

      That worked to move the text up - any ideas on how to move it horizontally to the left (I am using TextPosition.BottomRight)?

      Also, any suggestions re the second part of my first post?

      Thanks

      Comment


        #4
        You can try using \t for tabbing.

        For your second question you will need to dip into overriding the Plot method and using DrawText to achieve what you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,

          If in your example +"\n", adds a new line (above) what is the syntax to add a new line below.

          I have tried the obvious possibilities without success...

          It would be great if there were optional offset parameters within DrawTextFixed - any possibility that these can be added?

          Thanks

          Comment


            #6
            I'm not sure what would add a line below. \n means new line. You may want to play around with the various text alignments.

            Thanks for the suggestion.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_JoshP View Post
              Check out this reference sample. I use the technique of using line breaks to move them up from the fixed positions.

              http://www.ninjatrader-support.com/v...ead.php?t=4749
              Josh. The reference sample above no longer works (it's from 2007). Is there an alternative or new one for NT7. I am interested in the subject matter of moving the TextFixed either left/right or up/down.

              add edit: I found a reference when doing a google image search:

              DrawTextFixed("tag", "TEXT" + "\nline2", TextPosition.TopRight, Color.Blue, new Font ("Arial", 9, FontStyle.Bold), Color.Cyan, Color.Empty, 0);

              which should move it up/down. Is there a way to move it left/right?

              sandman
              Last edited by sandman; 03-22-2019, 05:46 AM.

              Comment


                #8
                Hello sandman,

                Thanks for your post.

                I've attached an example of how you can use the embedded escape codes to tab \t or create a new line \n.

                I've also attached a screenshot of the expected results.

                Click image for larger version

Name:	Sandman-3.PNG
Views:	565
Size:	28.4 KB
ID:	1052335

                ​​​​​​​
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_PaulH View Post
                  I've attached an example of how you can use the embedded escape codes to tab \t or create a new line \n.
                  I've also attached a screenshot of the expected results.
                  ​​​​​​​
                  Thank you very much Paul. Your sample allowed me to understand how it works so I could use it for my purposes with multi time frames.
                  I have another similar question but it concerns DrawText not DrawTextFixed so will open a new thread sometime soon.
                  sandman
                  Last edited by sandman; 03-24-2019, 11:31 AM.

                  Comment


                    #10
                    Okay, so I do have another question. The example is for using TopRight.

                    DrawTextFixed ("testa", "Open:", TextPosition.TopRight, Color.Black, mytextFont, Color.Transparent, Color.Red, 0);
                    DrawTextFixed ("testb", "\nHigh:", TextPosition.TopRight, Color.Black, mytextFont, Color.Transparent, Color.Blue, 0);
                    DrawTextFixed ("testc", "\n\nLow:", TextPosition.TopRight, Color.Black, mytextFont, Color.Transparent, Color.Transparent, 0);
                    DrawTextFixed ("testd", "\n\n\nClose:, TextPosition.TopRight, Color.Black, mytextFont, Color.Transparent, Color.Transparent, 0);

                    Is there a way to stack them up equally nicely when using BottomRight? i.e. How do you use "\n" as a line break, but upwards from BottomRight?

                    sandman





                    Comment


                      #11
                      Hello sandman,

                      Thanks for your reply.

                      You would need to do the same thing but in a different order. The very last line would have no "\n", the line above that would have one "\n" the line above that would have "\n\n" and the top line would have "\n\n\n" Here is an example of a top or bottom usage:

                      IsSuspendedWhileInactive = true;
                      BasisTextLocation = TextPosition.BottomLeft;
                      }

                      }

                      protected override void OnBarUpdate()
                      {
                      if (CurrentBar == 0 && BasisTextLocation == TextPosition.TopRight || BasisTextLocation == TextPosition.TopLeft )
                      {
                      Draw.TextFixed (this, "testa", "Line1", BasisTextLocation);
                      Draw.TextFixed (this, "testb", "\nLine2", BasisTextLocation);
                      Draw.TextFixed (this, "testc", "\n\nLine3", BasisTextLocation);
                      Draw.TextFixed (this, "testd", "\n\n\nLine4", BasisTextLocation);
                      }

                      if (CurrentBar == 0 && BasisTextLocation == TextPosition.BottomLeft || BasisTextLocation == TextPosition.BottomRight)
                      {
                      Draw.TextFixed (this, "testa", "Line1\n\n\n", BasisTextLocation);
                      Draw.TextFixed (this, "testb", "Line2\n\n", BasisTextLocation);
                      Draw.TextFixed (this, "testc", "Line3\n", BasisTextLocation);
                      Draw.TextFixed (this, "testd", "Line4", BasisTextLocation);
                      }

                      }

                      [Display(Name="Chart location for basis data/info", Description="", Order=4, GroupName="Pivots")]
                      public TextPosition BasisTextLocation
                      { get; set; }
                      }
                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello,

                        I just wanted to follow-up.

                        The code example I posted in #11 is actually NT8 specific code. Below is the NT7 equivalent:

                        {
                        #region Variables
                        private TextPosition myTextPosition = TextPosition.TopRight;
                        #endregion

                        protected override void Initialize()
                        {
                        Overlay = true;
                        }
                        protected override void OnBarUpdate()
                        {
                        if (myTextPosition == TextPosition.TopLeft || myTextPosition == TextPosition.TopRight)
                        {
                        DrawTextFixed("testa", "Line#1", myTextPosition);
                        DrawTextFixed("testb", "\nLine#2", myTextPosition);
                        DrawTextFixed("testc", "\n\nLine#3", myTextPosition);
                        DrawTextFixed("testd", "\n\n\nLine#4", myTextPosition);
                        }
                        else
                        {
                        DrawTextFixed("testd", "Line#4", myTextPosition);
                        DrawTextFixed("testc", "Line#3\n\n", myTextPosition);
                        DrawTextFixed("testb", "Line#2\n\n\n", myTextPosition);
                        DrawTextFixed("testa", "Line#1\n\n\n\n", myTextPosition);
                        }
                        }

                        #region Properties

                        [Description("Select corner to display in")]
                        [GridCategory("Parameters")]
                        [Gui.Design.DisplayName("Text Corner")]
                        public TextPosition MyTextPosition
                        {
                        get { return myTextPosition; }
                        set { myTextPosition = value; }
                        }
                        #endregion


                        I apologize for any confusion and hope that this will be helpful.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Using TextPosition.TopRight is fine. But when I'm trying TextPosition.TopLeft I am running into a problem as no matter where I place the "t" for tab it does not seem to work. See attached image which shows the scrambled numbers and arrows. Here is the code I am using. I guess I'm doing something wrong with the placement of the "t" and would appreciate a helping hand.

                          DrawTextFixed ("LAB16", "Daily\t", TextPosition.TopLeft, downlr, new Font ("Arial", fsize, FontStyle.Bold), Color.Transparent, Color.Empty, 0);
                          DrawTextFixed ("LAB16a", "î", TextPosition.TopLeft, downlr, new Font ("Wingdings", fsize, FontStyle.Regular), Color.Transparent, Color.Empty, 0);

                          DrawTextFixed ("LAB7", "\n720\t", TextPosition.TopLeft, downlr, new Font ("Arial", fsize, FontStyle.Bold), Color.Transparent, Color.Empty, 0);
                          DrawTextFixed ("LAB7a", "\nî", TextPosition.TopLeft, downlr, new Font ("Wingdings", fsize, FontStyle.Regular), Color.Transparent, Color.Empty, 0);

                          DrawTextFixed ("LAB6", "\n\n360\t", TextPosition.TopLeft, downlr, new Font ("Arial", fsize, FontStyle.Bold), Color.Transparent, Color.Empty, 0);
                          DrawTextFixed ("LAB6a", "\n\nî", TextPosition.TopLeft, downlr, new Font ("Wingdings", fsize, FontStyle.Regular), Color.Transparent, Color.Empty, 0);

                          etc.

                          sandman Click image for larger version

Name:	RTYTopLeft.jpg
Views:	952
Size:	53.2 KB
ID:	1065950

                          Comment


                            #14
                            Hello sandman,

                            Thanks for your reply.

                            I also had similar difficulties with this work around.

                            When selecting the left side you could just try using spaces between the text, for example:

                            DrawTextFixed ("LAB16", "Daily "+"i", TextPosition.TopLeft, downlr, new Font ("Arial", fsize, FontStyle.Bold), Color.Transparent, Color.Empty, 0);

                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              The solutions above add whitespace to the area below the text, if there's a background color or outline set, it looks terrible. Are there any solutions for this which don't involve editing the TextFixed drawing tool?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ghoul, Today, 06:02 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post ghoul
                              by ghoul
                               
                              Started by Barry Milan, Yesterday, 10:35 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post Barry Milan  
                              Started by DanielSanMartin, Yesterday, 02:37 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post DanielSanMartin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              13 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Working...
                              X