Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot get Draw.Text to show up on Charts :(

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

    Cannot get Draw.Text to show up on Charts :(

    Hello,

    As part of evaluating a strategy, I'd like to print on the chart a few different values, like the ATR, Trail Stop, etc. for each candle. However, I have been unable to even get a simple "Hello World" type of thing to show up. Here's what I've tried:

    First tried to add code right below where I'm using a Print command to write to the log. The code is

    Draw.Text(this, CurrentBar.ToString() + " Long Entry", "Test LONG Position Update", 0, High[0] + 5, Brushes.AntiqueWhite);

    It compiles just fine, but doesn't show up on the chart. I was expecting to see it $5 above the high of the candle in white. But I don't see anything.

    I tried it in Strategy Analyzer, and it didn't show up there. I then, created a new chart, added the strategy to the chart, and enabled it. The trade entries show up, but the Draw.Text doesn't.

    Finally, I tried using a Draw.Arrow command to see if it would show up. Again, it compiles, but it never shows up on the chart.

    Is there something else I have to add to the chart in order for these "draws" to show up?

    Thanks!

    #2
    I dunno. It's working for me. Printing "Test LONG Position Update over EVERY candle. What does your code look like? You're not using the previous bar, so you shouldn't be running into any out of bounds array errors.

    Comment


      #3
      This is a snippet; essentially whenever my trail stop value changes, I want to print it on the chart. Right now, I'm not worrying about pulling the variables in; just wanna get it to print SOMETHING!

      double newStop = Position.AveragePrice - (atrIndicator[0] * atrMultiplierStopLoss);

      if (newStop > trailingStop || trailingStop == 0)

      {

      trailingStop = newStop;

      Print($"[DEBUG] ***** LONG New Stop:: Time: {Time[0]}, Value: {newStop}, Trailing Stop Value: {trailingStop}, AvgPrice: {Position.AveragePrice}, ATR: {atrIndicator[0]}");

      Draw.Text(this, CurrentBar.ToString() + " Long Entry", "Test LONG", 0, High[0] + 5, Brushes.AntiqueWhite);

      SetStopLoss("BreakoutLong", CalculationMode.Price, trailingStop, false);

      }


      It all compiles fine, and the Print [DEBUG] statement shows up in the log consistently. So I'm at a loss.

      Comment


        #4
        Hello,

        Thank you for your post.

        To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition.

        The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

        The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

        Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        I am happy to assist you with analyzing the output from the output window.

        Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

        Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

        https://support.ninjatrader.com/s/ar...nd-TraceOrders

        Comment


          #5
          Originally posted by NinjaTrader_Gaby View Post
          Hello,

          Thank you for your post.

          To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

          In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition.

          The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

          The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

          Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

          I am happy to assist you with analyzing the output from the output window.

          Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

          Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

          https://support.ninjatrader.com/s/ar...nd-TraceOrders
          Thank you Gaby.

          I'm not evaluating any condition as part of the Draw.Text. It is contained within an IF statement, but all of the other lines of code within the IF statement are being executed, including printing a debug message just before, which shows up fine in the Output window. And the Draw.Text is not using any complex values, so I'm not sure what to actually "print" to ensure the values are correct. My assumption here is that it should write "Test LONG" on that candle.

          Can you suggest anything specific?

          Comment


            #6
            Is the drawing showing in the list of drawing objects on the chart?

            If not, this would suggest it's not being drawn at all so we would need to see the output from the prints.

            If it is, this would suggest it's just being drawn somewhere not in view.

            Comment


              #7
              Originally posted by NinjaTrader_Gaby View Post
              Is the drawing showing in the list of drawing objects on the chart?

              If not, this would suggest it's not being drawn at all so we would need to see the output from the prints.

              If it is, this would suggest it's just being drawn somewhere not in view.
              Where would I see the list of drawing objects on the chart?

              Comment


                #8
                Right-mouse click within the chart > Drawing Tools > Drawing Objects... and that will bring up the window.

                Comment


                  #9
                  Hi Gaby,

                  Sorry for the delay, as I thought I had this working, but it's not. Initially, I was trying to get the lines to show up on Strategy Analyzer charts, and once I set IsOverlay=true, it started working.

                  However, they aren't showing up on the live charts. They do not show as Drawing Objects on the live chart, but do show up as Drawing Objects on the Strategy Analyzer charts.

                  So I'm confused...

                  Comment


                    #10
                    Hi Gaby,

                    was just looking at some other posts. Could this be my issue?

                    Originally posted by ReedRd View Post
                    Ah...ok. That helped solve the mystery. Posting here in case anyone else has the same issue. For the drawing objects to show up, the strategy has to be instantiated/enabled through the GUI (ie right clicking in the chart and selecting Strategies).

                    If the strategy is enabled in the Strategies tab of the Control Center (I think that's what it's called), the objects won't draw. There might be something else I'm missing but I was able to get the Strategy to run in the Strategies window (ie it was enabled) and would produce output and even execute trades. But it just wouldn't draw objects.

                    Thanks Brandon!
                    ​I am, in fact, activating the strategy through the control center and not right clicking on the chart.

                    Comment


                      #11
                      Hello,

                      Yes, you need to be running the strategy on a chart in order for it to be able to draw objects on a chart.

                      Comment

                      Latest Posts

                      Collapse

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