Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 frankthearm, Yesterday, 09:08 AM
                12 responses
                43 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by junkone, Today, 11:37 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by quantismo, 04-17-2024, 05:13 PM
                5 responses
                35 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by proptrade13, Today, 11:06 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by love2code2trade, 04-17-2024, 01:45 PM
                4 responses
                35 views
                0 likes
                Last Post love2code2trade  
                Working...
                X