Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Easy Text Question

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

    Easy Text Question

    double y = High[0];
    Text myText = Draw.Text(this, getTag(), true, "myText", 0, y, 0, Brushes.Red, myFont, TextAlignment.Center, null, null, 1);

    How do I adjust the y position of myText?

    and AutoScale = True or False, what's the difference?
    Last edited by delTik; 09-13-2016, 07:38 AM.

    #2
    Hello delTik,

    Thanks for your post.

    You can change the vertical position by changing the value of y. Currently you are using the High[0] for y. If you wanted to be above the high you could add further price value such as y + 5 * TickSize. TickSize will represent the smallest movement of whatever instrument this is applied to. http://ninjatrader.com/support/helpG.../?ticksize.htm

    Autoscale = true in this instance would mean that the indicator that this is applied to, if it is set to autoscale = true, would include the vertical location of the text as part of the overall scaling of the indicator when applied to the autoscaling of the chart. Or said another way, ensures that the text will be visible on the chart.

    Comment


      #3
      sorru didn't make myself clear, I meant having drawn the the text then adjust e.g. the height a few ticks later.

      Comment


        #4
        Hello delTik,

        Thanks for your reply.

        You could redraw the text using the same tag and the new y location.

        Comment


          #5
          ok thanks, if I wanted to check if it was drawn on the current (last) bar would I use something like

          if (myText.Anchor.BarsAgo == 0)

          what I'd like to do is draw text on the current High[0] and the check if the same bar got higher and if so adjust the text.

          I can figure out how to do this with variables but wondered if there were any properties I could use in the Text object?
          Last edited by delTik; 09-13-2016, 08:55 AM.

          Comment


            #6
            Hello delTik,

            Thanks for your reply.

            Yes, you can use myText.Anchor.BarsAgo to check or set the X location and you can use myText.Anchor.Price to check or set the Y location.

            Comment


              #7
              ok thanks again.

              I tried setting myText.Anchor.Price but didn't work as expected. If High[0] at time of drawing is say 100 and then rises to 110, would I need to increase myText.Anchor.Price by (110-100). If so then it may be easier to "redraw the text using the same tag and the new y location"?

              Comment


                #8
                Hello delTik,

                Thanks for your reply.

                No, price would be the price to draw at. You should be able to use myText.Anchor.Price = High[0]; or myText.Anchor.Price = 110.0; Both of those work here.

                Comment


                  #9
                  ok not working for me.

                  can I ask if myText is drawn at y=100 what value would myText.Anchor.Price have?

                  I think the problem is my code, will figure out.
                  Last edited by delTik; 09-13-2016, 10:31 AM.

                  Comment


                    #10
                    Hello delTik,

                    Thanks for your reply.

                    I would expect it to be at the price of 100.

                    You can test this yourself, Print (myText.Anchor.Price);

                    Comment


                      #11
                      looks like a problem with myText.Anchor.BarsAgo

                      will try and put a sample together tomorrow if time.

                      Comment


                        #12
                        I don't have time to create a sample study but replaced

                        public Text myText;

                        if (myText.Anchor.BarsAgo == 0)

                        with

                        public int myTextBar

                        if (myTextBar == CurrentBar)

                        and it works ok

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        656 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        371 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        574 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        579 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X