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

DrawText not working

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

    DrawText not working

    What would stop DrawText or DrawDiamond from placing the text/marker on price BESIDES DrawOnPricePanel (which equals true) ??

    It is frustrating because the exact same code in other places does work. Yet this does not:
    Code:
     DrawOnPricePanel = true; 
     Font     ptFont = new Font("Arial", 8, FontStyle.Regular, GraphicsUnit.Point);
     DrawText("test", AutoScale, "NOW", 0, Close[0], 0, Color.Black, ptFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 10 );
    I can get alerts and output print statements, but nothing on the chart.
    I've done this many times before, so it is really bugging that I am missing something.

    #2
    Lost Trader, we'll take a look into this and get back to you.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Please check Control Center logs for errors.

      DrawOnPrice panel should be in Initialize(). DrawText should be in OnBarUpdate().
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        No errors in the log.

        It has never been an absolute REQUIREMENT that DrawOnPricePanel be ONLY in the Initialize method. It works in OnBarUpdate() when needed in an indicator that first draws on Price (set to true) and later in the indicator panel (set to false), all within OnBarUpdate().

        There must be something else, because this is not logical.

        Comment


          #5
          Please provide the complete script then for us to examine on our end.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            kind of figured you would say that. However, it is part of a larger package which I am not allowed to upload.

            Let me know if anything comes to mind. . .

            Comment


              #7
              Try with the simpler signature:

              DrawText(string tag, string text, int barsAgo, double y, Color color)

              That will remove the complexity of the Font.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                I tried
                DrawText("tag1", "Text to draw", 0, High[0], Color.Black);
                and DrawDiamond and DrawTriangleUp but still no output.

                What's really wierd is that there is NO output ANYWHERE, in any panel.
                If it were because of DrawOnPricepanel, then you would think the text would show up in the indicator window, but it isn't there either.

                Comment


                  #9
                  Lost Trader,

                  Check your Control Center logs for errors. All I can suggest is for you to strip down your code to bare basics and try again. Then slowly add layers of complexity till you find where it breaks.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    As I indicated below, there are no errors in the log.

                    By working on a blank chart, with just the test code, I discovered that placing the DrawOnPricePanel immediately after the last Draw command to the indicator panel vs. right before the Draw command to the price panel, changed the behavior (it worked) tho it should not matter, as long as the command is before the Draw instruction.

                    However, it still was not working on the original workspace. I know that if a plot command is changed, it is necessary to remove the indicator from the chart and re-apply it. This has never been necessary when only changing calculations or Draw statements. But since it now worked for certain on a new chart, I removed it completely from the original and re-applied. To get indicators back in sequence, this meant pulling everything off and rec-creating the chart completely.

                    At least it is now writing as it should.

                    Comment


                      #11
                      Using DrawOnPricePanel outside of Initialize() is not recommended. Any behavior of such is beyond what we can support.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by junkone, Today, 11:37 AM
                      2 responses
                      14 views
                      0 likes
                      Last Post junkone
                      by junkone
                       
                      Started by frankthearm, Yesterday, 09:08 AM
                      12 responses
                      43 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      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
                      7 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