Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Text

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

    Draw.Text

    Hello,

    I have a hard time in a room to follow because I have no TPO-letters in my chart in NT as it is in ....... (I dont write the name of this software here).

    So I modified me an indicator from the thread https://ninjatrader.com/support/foru...1680-barnumber but the plotting of the letters is not in the center of the bar, I resolved for now with adding a "." to the Draw.Text as you see here for peridod A and B. But when working with more narrow bars the"." is distracting. I think there will be a solution to have the letter in the center of the bar without additional "." What do I have to modify please for having only "A", "B"... right in the center of the bar? (or is there a "invisible" space possible? with "A " it does not work)

    Thank you!
    Tony
    Attached Files
    Last edited by tonynt; 10-16-2020, 02:30 AM. Reason: add info

    #2
    Hello tonynt,

    Thanks for your post.

    You can use the Draw.Text() method overload that allows you to specify "Text alignment" Choices are left, right, center, or Justify.

    Here is the overload that allows Text alignment:
    Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)

    Please see the help guide here for details: https://ninjatrader.com/support/help...?draw_text.htm

    Comment


      #3
      Hello,

      I use "Textalignment.Center" as it is in this indicator, but as you see in the screenshot it does not plot at center of bar (I mean it has not to be exactly, but it is not at center)

      Draw.Text(this, CurrentBar.ToString(), true, "B.", 0, High[0], _pixelsAboveBelowBar, _textColorDefinedbyUser, myFont, TextAlignment.Center, null, null, 1);

      Thank you!
      Tony

      Comment


        #4
        Hi tonynt, search "yPixelOffset" in NT8 Help under Draw.Text(). If it is not zero, then expect your text to be shifted above/below center because yPixelOffset shifts your text vertically by the number of pixels specified.

        Comment


          #5
          Hello,

          thank you for your reply. Why "above/below", this is not the question. Yes, there is yPixelOffset.

          Center - left - right is the topic.

          Tony

          Comment


            #6
            Hello tonynt,

            Thanks for your reply.

            Here is an example, using most of your Draw.Text() and it looks like the letter is center on the bar.
            I did set the ypixeloffset to 0 as I didn't know what your parameter value was.
            I used Arial font as I didn't know what you used.

            Please see if you can recreate my example and advise if the letters remain offset.


            Click image for larger version

Name:	TonyNT-9.PNG
Views:	1264
Size:	97.1 KB
ID:	1123026

            Comment


              #7
              Hello,

              thank you for your reply. I found the reason. With candlesticks it works but not with Box. But as NT has no profile tpo I have to use box, and there it is not plotting in the center.

              ???

              Thank you!
              Tony

              Comment


                #8
                Hello Tony,
                Box starts from mid of each bar & candle is distributed about the mid of each bar so you're seeing this difference. Text is aligned at center so instead of modifying the text try to use Open Close candle style, I think it will work best for you & avoid any confusions. Hope it helps!

                Comment


                  #9
                  Hello tonynt,

                  Thanks for your reply.

                  Yes, a candlestick will draw from it center left and right to the candle width whereas a box type will draw from center to center.

                  With that in mind, there are no Draw settings that will be ideal using a box type. You can certainly adjust with spaces but every time you change the time scale the alignment will be off.

                  The best solution, using Box type, would be custom programming using OnRender().

                  Comment


                    #10
                    Hello,

                    yes there is OpenClose candle style. Of course this would work. Are you using marketprofile from some software? Then you would know that OpenClose makes no sense in this concern.

                    Tony

                    Comment


                      #11
                      Hello tonynt,

                      Thanks for your reply.

                      I don't know if this will work for you, but you could use the chart style of OHLC and then choose a HiLo bar.

                      You can enlarge the bar width as you wish and Draw.Text() will be centered on it.

                      Comment


                        #12
                        Sorry tonynt, my bad. If left-right is the concern, you do know the high & low & TPO letter for each period, so it is simple enough to hide the normal bars and then plot your own expanded profile using either Draw.Text or OnRender approaches.

                        Comment


                          #13
                          Hello guys,

                          thanks for your reply. In the meantime I worked round with box, changed alignment to right, then changed the barnumbers and now its ok.
                          And also the solution with OHLC/HL is working.

                          Hey, Paul, maybe you could have a look on my other question here in NT8 indicators, maybe we can resolve this fast as well.

                          Thank you!
                          Tony
                          Last edited by tonynt; 10-16-2020, 09:46 AM.

                          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