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 Barry Milan, Today, 10:35 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by WeyldFalcon, 12-10-2020, 06:48 PM
                14 responses
                1,428 views
                0 likes
                Last Post Handclap0241  
                Started by DJ888, Yesterday, 06:09 PM
                2 responses
                9 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                40 views
                0 likes
                Last Post jeronymite  
                Started by bill2023, Today, 08:51 AM
                2 responses
                16 views
                0 likes
                Last Post bill2023  
                Working...
                X