• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

    http://www.ninjatrader-support.com/v...ead.php?t=4749
    JoshNinjaTrader 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.
        JoshNinjaTrader 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.
            JoshNinjaTrader 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:	1
Size:	28.4 KB
ID:	1052335

                ​​​​​​​
                Attached Files
                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
                        Thanks for sharing this post.

                        Comment


                          #13
                          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

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by akitenge, 06-14-2019, 02:54 PM
                          4 responses
                          28 views
                          0 likes
                          Last Post chartish  
                          Started by siriusm, Today, 09:15 AM
                          2 responses
                          12 views
                          0 likes
                          Last Post siriusm
                          by siriusm
                           
                          Started by Duval, Today, 09:27 AM
                          4 responses
                          10 views
                          0 likes
                          Last Post Duval
                          by Duval
                           
                          Started by chazyang, Today, 08:11 AM
                          2 responses
                          9 views
                          0 likes
                          Last Post chazyang  
                          Started by Erwin Beckers, 11-04-2018, 02:39 AM
                          6 responses
                          79 views
                          2 likes
                          Last Post koganam
                          by koganam
                           
                          Working...
                          X