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


Strategy won't draw any objects on chart

  • Filter
  • Time
  • Show
Clear All
new posts

    Strategy won't draw any objects on chart

    I cannot get any strategy I create to Draw a single objects on the chart. No text, no lines, no arrows. I can get my strategies to place orders but not draw anything.

    - The strategy is enabled
    - Whether on bar close or on price change is selected makes no difference.
    - I give each object a unique string from the CurrentBar
    - Right clicking the chart and looking at all the drawings on the chart. None are ever drawn by the strategy.
    - I put a Print() inside my condition to print the price every time the condition is true and the price prints but never any drawings.

    It must be something something I'm missing but unsure what.

    Click image for larger version  Name:	Screenshot 2024-06-23 at 16.29.28.png Views:	0 Size:	209.4 KB ID:	1308229
    Last edited by lucyb; 06-23-2024, 12:19 PM.

    Hello lucyb,

    Thank you for your post.

    To understand why the script is behaving as it is, such as not placing drawing objects or other actions 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 values of every variable used in every condition that places an order along with the time of that bar.

    This will print to 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.

    Output from prints will appear in the NinjaScript Output window.
    NT8: New -> NinjaScript Output

    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 helpful to include labels and operators in the print to understand what is being compared in the condition sets.

    Below I am providing a link to videos that demonstrate adding prints to a script to get further information about the behavior of the script.
    NT8 —

    If you are using the Strategy Builder in NinjaTrader 8, you can also build prints in the Actions window under Misc -> Print.
    NT8 Strategy Builder —

    I'm also including a link to a forum post with further suggestions on debugging a script.

    Save the output from the output window to a text file. Let me know if you need assistance creating a print.

    I am happy to assist with analyzing the output from prints.​
    Gaby V.NinjaTrader Customer Service


      I made a basic test and added prints in a set with no conditions.

      The strategy checks if the current price is greater than 1 on each bar. If so, draw a diamond above the previous candle. Nothing happens. Nothing is ever drawn.

      The output from the strategy is simply this:

      Disabling NinjaScript strategy 'DrawingTest/327706414'
      // Current Ask 5564.5 // Current Bar 1 // Time 02:22:30.1440000
      // Current Ask 5567.25 // Current Bar 2 // Time 03:03:47.0760000
      // Current Ask 5568 // Current Bar 3 // Time 03:46:40.4720000
      // Current Ask 5565.5 // Current Bar 4 // Time 04:47:06.1680000
      // Current Ask 5569.75 // Current Bar 5 // Time 05:45:36.4640000
      // Current Ask 5571.5 // Current Bar 6 // Time 06:18:51.7440000
      // Current Ask 5573.75 // Current Bar 7 // Time 07:00:00.2440000
      // Current Ask 5576.25 // Current Bar 8 // Time 07:11:15.3440000
      // Current Ask 5578 // Current Bar 9 // Time 07:41:28.0880000​
      etc etc etc

      Is there any other info you need? There's no mention or reference to any drawings. As you can see the price is greater than 1 on each bar.

      I'm using NinjaTrader 8 inside a virtual machine, do you think this is related issue? I can manually draw no problem.
      Attached Files



        Can you share an export of your script here so I can test it out on my end?

        To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
        1. Click Tools -> Export -> NinjaScript Add-on...
        2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
        3. Click the 'Export' button
        4. Enter a unique name for the file in the value for 'File name:'
        5. Choose a save location -> click Save
        6. Click OK to clear the export location message
        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<>
        Below is a link to the help guide on Exporting NinjaScripts.

        Once exported, please attach the file as an attachment to your reply.​
        Gaby V.NinjaTrader Customer Service


          Here you go, thanks.
          Attached Files


            Hello lucyb,

            How was this script exported - Are you using a Mac? I am seeing a MACOSX_ folder in this .zip which would not be included in NinjaScript exports. Please note that NinjaTrader is a Windows application and is not supported on MacOS.

            That being said, when I copy the code straight from the .cs file and test it I am able to see the drawings on the chart.

            Is the strategy enabled on your chart? Are you connected to data?
            Attached Files
            Gaby V.NinjaTrader Customer Service


              Hey, I'm running it in Windows 11. I use a virtual machine on a Mac computer.

              Strategy is enabled and data is connected. other strategies can run.


                Hello lucy,

                This would seem to be isolated to something on your set up, since I am able to run the script and see the drawing objects. The code also looks fine.

                Who are you connected to for data? What instrument + expiry are you running the script on?

                Are you seeing any errors in the Log tab of the Control Center?
                Gaby V.NinjaTrader Customer Service


                  No errors, ES E-mini. Most recent contract 09-24. Standard ninjatrader data. There's nothing at all in the Log tab in relation to this script. As if the drawing component simply doesn't work inside my setup.

                  I use UTM, which is like parallels desktop.


                    Hello lucyb,

                    Are you able to test on another Windows computer? I suspect something may to do with your virtual machine / set-up could be interfering - NinjaScripts exported from the platform should not have any reference to MACOSX within the .zip folder.
                    Gaby V.NinjaTrader Customer Service


                      I sent the files from Mac OS. That's why you see it there. NT8 > Windows explorer > Mac finder > here. Finder auto unzipped the files, I zipped it back up.



                        Thanks for clarifying.

                        Still, are you able to test on a different Windows PC?

                        I tested the strategy on an ES 09-24 1 minute chart - if you apply it to the same chart, are you not seeing any results? Make sure the strategy is checked as 'Enabled'.

                        Can you post a screenshot of what you see on the chart when you run it?
                        Gaby V.NinjaTrader Customer Service


                        Latest Posts


                        Topics Statistics Last Post
                        Started by TiffanyMiller, Today, 10:19 PM
                        0 responses
                        Last Post TiffanyMiller  
                        Started by JackyP, 07-25-2023, 08:39 AM
                        2 responses
                        Last Post j4trdr
                        by j4trdr
                        Started by algospoke, 05-13-2024, 06:53 PM
                        12 responses
                        Last Post algospoke  
                        Started by psangram, Today, 06:35 PM
                        0 responses
                        Last Post psangram  
                        Started by Alaina19, Yesterday, 04:38 PM
                        2 responses
                        Last Post Alaina19