Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawText Question

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

    DrawText Question

    Hello

    Is it possible to use the DrawText command to draw text ANYWHERE on the chart (for example in the lower right corner) or can it only be used with reference to a specific bar (x axis co-ordinate). I'd like to draw custom text in the lower right chart corner (similar to the DrawTextFixed command), but I'd like to do it with the DrawText command because objects drawn with the DrawTextFixed command cannot be manually removed afterwards, which is very important to me.

    Thanks

    #2
    Hello,

    Thanks for the note.

    DrawText works only in relation to Bars.

    You would need to use DrawTextFixed for this, if you needed to remove DrawTextFixed you could set it to a blank string would do the trick easily.

    " "

    -Brett

    Comment


      #3
      Hello Brett

      Thanks for your reply. I'm currently using the DrawTextFixed command, but I'm looking to remove the text MANUALLY (by clicking on it and hitting "delete"). This works well with the DrawText command, but not with DrawTextFixed. The solution you're suggesting is great, but has obviously to be integrated into the code, which is not possible in my case.

      Thanks

      Comment


        #4
        Hello,

        Unfortunately that would not be supported however I will send this into development for there review.

        Thank You.

        Comment


          #5
          Thanks for that Brett.
          I have already suggested this in another thread and it has been assigned tracking id # 1490.

          Thanks again.

          Comment


            #6
            Originally posted by laocoon View Post
            Hello Brett

            Thanks for your reply. I'm currently using the DrawTextFixed command, but I'm looking to remove the text MANUALLY (by clicking on it and hitting "delete"). This works well with the DrawText command, but not with DrawTextFixed. The solution you're suggesting is great, but has obviously to be integrated into the code, which is not possible in my case.

            Thanks
            You can use DrawText() if you can figure out the y-position using the undocumented ChartControl methods. If you are going that route, then it may actually be easier to just use a Custom Plot and DrawString(). Look at the shipping CustomPlotSample.cs file, which actually has listed how to draw text in the "Lower left corner", which I believe is what you are seeking!

            If DrawString() does not allow removal (I have not tried it out), and you must use DrawText(), you can still determine the y-position by using the methods in the CustomPlot.cs file. For the x-position, you will need a barsAgo value that specifies the left edge of the screen. This post of mine tells you how to do that. http://www.ninjatrader.com/support/f...43306#poststop

            The usual caveats of no NT support for ChartControl apply.

            Comment


              #7
              Thanks a lot for your input koganam, I'll look into it.
              I'm looking to draw text in the lower RIGHT corner, but I guess this could be achieved with your suggested solution as well.

              Have a great day.

              Comment


                #8
                Hello Koganam,

                I've implemented your example and it works well, thanks again for helping me out here.
                The last thing I'm now trying to do is to get the Text to plot on the RIGHT side of the chart (instead of the Left side). Is this feasible with the solution you offered?

                Thanks again.

                Comment


                  #9
                  Koganam,

                  I just found the solution to my problem. This will draw a big "X" on the RIGHT side of the chart:

                  int RightSideOfScreen = ChartControl.LastBarPainted;
                  DrawText("Test", false, "X",
                  (CurrentBar - RightSideOfScreen), Close[0], 0, Color.Black, new Font("Arial" , 40),
                  StringAlignment.Near, Color.Transparent, Color.Transparent, 5);

                  Is there a way to "fine-tune" the exact location where the text will be drawn using "Bounds" or another command? By "fine-tune" I mean to move the text a bit (1-2 centimeters) to the left for example?

                  Thanks
                  Last edited by laocoon; 03-01-2012, 06:56 AM.

                  Comment


                    #10
                    Originally posted by laocoon View Post
                    Koganam,

                    I just found the solution to my problem. This will draw a big "X" on the RIGHT side of the chart:

                    int RightSideOfScreen = ChartControl.LastBarPainted;
                    DrawText("Test", false, "X",
                    (CurrentBar - RightSideOfScreen), Close[0], 0, Color.Black, new Font("Arial" , 40),
                    StringAlignment.Near, Color.Transparent, Color.Transparent, 5);

                    Is there a way to "fine-tune" the exact location where the text will be drawn using "Bounds" or another command? By "fine-tune" I mean to move the text a bit (1-2 centimeters) to the left for example?

                    Thanks
                    For such fine control of the x-position, you are almost certainly going to need to use DrawString(): DrawText() is keyed to the barIndex for its horizontal placement.

                    Comment


                      #11
                      I understand Koganam, thanks for that.

                      Is it possible to move custom text on the X-Axis AT ALL with DrawText() and the barIndex?
                      I'm not looking for a precise location of the custom text, just need to have it further away from the right chart corner (a bit towards the left)

                      Thanks

                      Comment


                        #12
                        Originally posted by laocoon View Post
                        I understand Koganam, thanks for that.

                        Is it possible to move custom text on the X-Axis AT ALL with DrawText() and the barIndex?
                        I'm not looking for a precise location of the custom text, just need to have it further away from the right chart corner (a bit towards the left)

                        Thanks
                        Your x-position is (CurrentBar - RightSideOfScreen), the barsAgo value. Assume that you want to move the text xOffset bars to the left, then use:

                        (CurrentBar - RightSideOfScreen + xOffset)

                        for the barsAgo value.

                        Comment


                          #13
                          Brilliant, you made my day Koganam, thank you so much!

                          Comment


                            #14
                            One last thing:

                            My previous solution looked like this:

                            if (my conditions here)
                            { DrawTextFixed("tag1", "X", TextPosition.BottomRight, Color.Black, new Font("Arial", 55), Color.Black, Color.Transparent,2);
                            }

                            else RemoveDrawObject("tag1");

                            This means that the DrawTextFixed object is removed if a new bar opens and the conditions are no longer valid. This works perfectly.

                            Now, with the new code, the object is no longer removed once the bar is closed. Any hint on why this happens is much appreciated.

                            The new code snippet that replaces the old one looks like this:

                            DrawText("tag1", false, "X", (CurrentBar - RightSideOfScreen + 23), Close[0], 0, Color.Black, new Font("Arial" , 55), StringAlignment.Near, Color.Transparent, Color.Transparent, 5);


                            Thanks

                            Comment


                              #15
                              Originally posted by laocoon View Post
                              One last thing:

                              My previous solution looked like this:

                              if (my conditions here)
                              { DrawTextFixed("tag1", "X", TextPosition.BottomRight, Color.Black, new Font("Arial", 55), Color.Black, Color.Transparent,2);
                              }

                              else RemoveDrawObject("tag1");

                              This means that the DrawTextFixed object is removed if a new bar opens and the conditions are no longer valid. This works perfectly.

                              Now, with the new code, the object is no longer removed once the bar is closed. Any hint on why this happens is much appreciated.

                              The new code snippet that replaces the old one looks like this:

                              DrawText("tag1", false, "X", (CurrentBar - RightSideOfScreen + 23), Close[0], 0, Color.Black, new Font("Arial" , 55), StringAlignment.Near, Color.Transparent, Color.Transparent, 5);


                              Thanks
                              RemoveDrawObject() definitely works correctly with DrawText(). My MarketExhaustion indicator removes multiple text many times when conditions warrant. All I can suggest is the you look closely at your code to find the error. Try making the draw object removal a code block, and use a Print() statement to see if the block is ever entered.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              12 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X