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

Drawing Tool Chart Anchor Slot Indexes assigned -1 after Adding Indicator

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

    Drawing Tool Chart Anchor Slot Indexes assigned -1 after Adding Indicator

    The BarIndex and SlotIndex properties of drawing tool chart anchors are assigned a value of -1 after adding an indicator to the chart. Calling ChartAnchor.GetPoint() before using the SlotIndex results in the SlotIndex being updated and is a work around. Note that OnEdited() for Drawing Tools is not called after an indicator is added to the chart (as expected), but the BarIndex and SlotIndex values of chart anchors are modified and assigned the invalid value of -1.

    I'm using version 8.0.22.2 of NinjaTrader 64-bit.

    #2
    What I have described is not the full story. Still trying to fully understand what is happening. Here is the history:

    - Originally did all computations involving the SlotIndex property of drawing tools in the MouseMove and OnEdited event handlers. I would see corruptions occuring once every few months or so when charts are reloaded for some reason.

    - Moved the computations involving the SlotIndex property of drawing tools to the OnRender event handler. This caused a higher frequency of corruptions and I saw the behaviour described in the original post.

    - I have since rewritten all drawing tools and moved the computations involving the SlotIndex property back to where they were. I'm currently seeing no corruptions occuring when adding or removing moving averages to the chart that already has the drawing tools added. However, I'm expecting that I'll encounter a corruption within the next 6 months.

    When I experience a corruption I either restore a non-corrupted version or start again with a fresh install of NinjaTrader 8. At this point I'm thinking I will avoid adding indicators to the chart that has the drawing tools that use the SlotIndex property and see how that goes. If a corruption occurs then I'll try to reproduce it in debug mode.

    All I'm really confident of is that the SlotIndex of drawing tools being assigned a value of -1 is part of the issue. I don't understand why that occurs at this point though.

    Comment


      #3
      Hello henry_aclitus,

      I'm happy to take a look with you.

      Are you manually drawing the object on the chart?
      Are you drawing within the bars on the chart, or are you drawing into the blank space to the right of the last bar on the chart?
      Are you printing to the output window to see what values are being calculated and set?

      May I have an export of the script?

      To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
      1. Click Tools -> Export -> NinjaScript...
      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/<export_file_name.zip>
      Below is a link to the help guide on Exporting NinjaScripts.
      http://ninjatrader.com/support/helpG...-us/export.htm

      Once exported, please attach the file as an attachment to your next post.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you for replying Chelsea.

        "Are you manually drawing the object on the chart?"

        Yes. There are upwards of 10 drawing tools that make use of the SlotIndex property to do some calculations.

        "Are you drawing within the bars on the chart, or are you drawing into the blank space to the right of the last bar on the chart?"

        There will always be some drawing tools that both use the SlotIndex and extend into the future. Approximately 4 or so.

        "Are you printing to the output window to see what values are being calculated and set?"

        No, I've been debugging using Visual Studio 2019. Printing to the output window is a good idea thanks.

        "May I have an export of the script?"

        Unfortunately, for me, I can't provide the scripts.

        When I start NinjaTrader 8 and the data source is connected, I see the charts load and the drawing tools are all swiftly rendered. Then while the data source is connecting, the drawing tools are rendered so they stack up along the left of the chart. When the data source has connected they are then rendered again and are back into postion. I think it is during the final rendering that the potential for corruption occurs. Having a moving average on the chart as well probably increases the chance of a corruption occurring, but isn't the cause. It might be a multithreading issue, but that is a guess.

        Everything appears to be solid since the last rewrite and refactoring of the drawing tools. Although, I'm expecting a corruption to occur once I have hundreds of drawing tools on the daily chart and enough time has passed. It will probably be 2 to 6 months before this happens. At least, that is what has happened in the past.

        Comment


          #5
          Hello henry_aclitus,

          This is Jim, responding on behalf of Chelsea who is out of the office at this time.

          I may add the following suggestions:

          1. Use the Playback Connection in an effort to quickly reproduce issues that occur when using these tools in Realtime
          2. Keep track of actions taken in an effort to reduce the circumstances needed to reproduce so you are left testable scenario to investigate further.

          Playback - https://ninjatrader.com/support/help...connection.htm

          I understand that you cannot share the full source code, and we would preferably not want to work with the full script. If you can reduce the problematic scenario to a testable case, and are able to create a separate test script that demonstrates the same issues that does not have anything proprietary included, you can email it to our NinjaScript team at platformsupport [at] ninjatrader [dot] com. You can include the text "Attn Jim 2709650" or "Attn Chelsea 2709650" with a link to the thread and the ticket will be received by Chelsea or me. We would then be able to share some insight on what further steps can be taken if we are able to test and reproduce those symptoms.

          We look forward to assisting.
          JimNinjaTrader Customer Service

          Comment


            #6
            Hi Jim,

            I was thinking of potentially reproducing the issue making use of AutoIt or similar. This is what I have been thinking of doing:

            1 - Backup my current workspaces.
            2 - Add hundreds of drawing tools to a daily chart.
            3 - Save the contents of \Documents\NinjaTrader 8\ as my test workspace so I can use it again if it does become corrupted.
            4 - Use AutoIT or a similar scripting/automation program to 'hammer' NinjaTrader 8 by repetitively reloading the scripts, refreshing the data source, adding new drawing tools, deleting drawing tools, editing drawing tools properties, adding editing and removing indicators etc. This would be done in a loop so it can run indefinitely.

            I could then run the automation script overnight with NinjaTrader in debug mode set to break on all errors. Maybe the NinjaTrader developers already do something similar. It would be a good idea for me to do this regardless.

            Thanks,
            Henry
            Last edited by henry_aclitus; 08-30-2020, 07:56 PM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kujista, Today, 06:23 AM
            0 responses
            1 view
            0 likes
            Last Post kujista
            by kujista
             
            Started by traderqz, Yesterday, 04:32 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by f.saeidi, Today, 05:56 AM
            1 response
            4 views
            0 likes
            Last Post Jltarrau  
            Started by Jltarrau, Today, 05:57 AM
            0 responses
            4 views
            0 likes
            Last Post Jltarrau  
            Started by Stanfillirenfro, Yesterday, 09:19 AM
            7 responses
            52 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X