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.
    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        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.
            Paul H.NinjaTrader Customer Service

            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.
                Paul H.NinjaTrader Customer Service

                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);
                    Paul H.NinjaTrader Customer Service

                    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 proptrade13, Today, 11:06 AM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by quantismo, 04-17-2024, 05:13 PM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by love2code2trade, 04-17-2024, 01:45 PM
                        4 responses
                        34 views
                        0 likes
                        Last Post love2code2trade  
                        Started by cls71, Today, 04:45 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post eDanny
                        by eDanny
                         
                        Started by kulwinder73, Today, 10:31 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Working...
                        X