Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing objects not appearing on chart

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

    Drawing objects not appearing on chart

    Hello,

    Working on a simple strategy and would like to create an up (or down) arrow every time a certain bar appears. I can identify the bar in my script and see the logic working on the output window, but can't get anything to draw on the chart. I've even added as the first line in the OnBarUpdate call (before any logic gets called), but nothing gets drawn. I'm running a historical playback and just have the following line:

    Draw.ArrowUp(this, arrowUp, true, 0, Low[0] - TickSize, Brushes.Red); // Draw the arrow

    Is there anything that might prevent this from working? I'm thinking it could be a configuration issue as I ran one of the sample strategies that seemed to add some drawing to the chart and while it was executing, nothing was being drawn.

    Thanks in advance for the help!

    #2
    Hello ReedRd,

    Thanks for your post.

    If you do not see the script drawing objects when expected then it is likely that the condition to draw the object is not evaluating as true or there could be an issue with your Draw.ArrowUp() method syntax.

    I do see in the code you shared that you are passing in an arrowUp variable for the string tag argument for Draw.ArrowUp(). If your arrowUp variable is not a string then this could be why the drawing object is not drawing when expected.

    Draw.ArrowUp(NinjaScriptBase owner, string tag, bool isAutoScale, int barsAgo, double y, Brush brush)\

    See this help guide page for more information about Draw.ArrowUp() and sample code: https://ninjatrader.com/support/help...aw_arrowup.htm

    Ultimately, debugging steps using prints would need to be taken to determine how the script is behaving and processing logic.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks for the help. I did add this line as the very first line of the OnBarUpdate call so it would get triggered every time a bar was drawn:
      Draw.ArrowUp(this, "tag", true, 0, Low[0] - TickSize, Brushes.Red); // Draw the arrow

      It's not drawing on the grid, but 'print' statements from the OnBarUpdate are showing up in the output window...so I know the code is executing. I've resorted to adding EnterShort() and EnterLong() statements to trigger 'trades' on the signal bars to see if my logic is working, as those are showing on the chart.

      Again, I've used other example strategies that are supposed to draw and there is no drawing that is taking place on the chart. Thus...thinking I may have something not configured correctly.

      Comment


        #4
        Hello ReedRd,

        Thanks for your note.

        Please see the attached example script which calls Draw.ArrowUp() at the beginning of the OnBarUpdate() method to draw an arrow on the chart 1 Tick below the Low[0] price.

        When we enable the attached example strategy on a chart window, we see a red arrow drawn 1 Tick below the Low[0] price. You could compare this example script to your script to see where in your script the error might be.

        Note to keep an eye on the Log tab of the Control Center when enabling your strategy for any errors that may appear.

        Let us know if we may assist further.
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thanks. I uploaded that code and also added some lines so every time a bar closes, there would be output (low and high values) to the output window. It's obviously triggering on bar close (there is output in that window), but still no arrow is showing up. I did turn warning compilation errors on and do have a warning on 'arrows.cs': Warning: Identifier 'NinjaTrader.NinjaScript.DrawingTools.MyChartMaker .ArrowSize' differing only in case is not CLS-compliant. Not sure that has anything to do with the issue (other drawing indicators also don't work) or it is some GUI configuration issue.

          Click image for larger version

Name:	Screenshot 2022-05-03 164333.png
Views:	714
Size:	406.4 KB
ID:	1199863

          Comment


            #6
            Should also have mentioned...though might be apparent from above, that I'm using market replay or historical, so maybe that's the issue?

            Comment


              #7
              Hello ReedRd,

              Thanks for your note.

              Unfortunately, I cannot see the code in the photo that you shared because the text is too small to read and I cannot enlarge the image. However, I understand that you modified the previously attached script to print the High and Low price and are using the script on a chart while connected to the Playback connection.

              To print out the High or Low price, the code would look something like below.

              Print("High price: " + High[0]);
              Print("Low price: " + Low[0]);


              When testing the previously attached example script on my end, I see that the script does work with the Playback connection. See this video demonstrating the strategy working on the Playback connection: https://brandonh-ninjatrader.tinytak...NV8xOTQzNDQ4MA

              I see that the Playback connection is paused in your screenshot. Note that the strategy must be enabled and the Playback must be playing data for the strategy to run and draw the arrow on the chart.

              Let us know if we may assist further.
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                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!

                Comment

                Latest Posts

                Collapse

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