Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Positioning text using DrawText()

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

    Positioning text using DrawText()

    I am drawing an UpArrow on my chart at various locations. I would like to draw text at a fixed distance below the arrow. Can someone tell me how to do this? I am drawing the arrow at Low[0] - .5 * TickSize. If I position the text at a multiple of TickSize such as Low[0] - 2 * TickSize then the distance below the arrow varies depending on how compressed the chart gets when there are large price variations. I would like the text to be a fixed distance below the arrow always. Thanks.

    #2
    Please take a look at this syntax version for DrawText()

    DrawText(string tag, bool autoScale, string text, int barsAgo, double y, double yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color backColor, int opacity)

    I think the yPixelOffest parameter can be useful in your case.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      hmm, please explain DrawText() positioning...

      I'm using this:
      DrawText("ask", false, "Ask: "+askRows[0].Price + " Vol: "+askRows[0].Volume, 0, High[0], 100, Color.Red, font, StringAlignment.Far, Color.Transparent, Color.Transparent, 50);

      I want the text to be the X= 5 (five bars back from currentbar), and Y = HighestBar(High, 20) but whenever I use those values I see NO text anywhere. If I plugin the above values they show up ok.

      Comment


        #4
        Try this code instead:
        Code:
        DrawText("test", false, "Test Text", [B][COLOR=Red]5[/COLOR][/B], [COLOR=Red][B]MAX(High, 20)[0][/B][/COLOR], Color.Red, new Font("Arial", 12), StringAlignment.Far, Color.Transparent, Color.Transparent, 50);
        The 5 is for the x axis and you want to use the MAX() to find the highest high instead of HighestBar().
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          re:

          Well, the problem is the "5", unless I use "0" for X, I don't see it. Why? I tried your code, did not see it, I replaced 5 with 0 and it shows up.

          Comment


            #6
            Check your Control Center logs. You most likely need to put in a
            Code:
            if (CurrentBar < 5)
                 return;
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              re: that was it

              Yes. Ok, so can I get the data to update like T&S? Instead of just OnBarUpdate()? I want to get the bid and ask, as they come in, not wait till chart updates it, is that possible?

              Comment


                #8
                Sure. Check out the advanced methods OnMarketData() or OnMarketDepth().
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                647 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X