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

Chart Drawing created from AddOn doesn't redraw after Reload All Historical Data

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

    Chart Drawing created from AddOn doesn't redraw after Reload All Historical Data

    Hi there,

    I have created an AddOn that creates a drawing in the chart using an indicator I created. The indicator is very simple and I just use it to refresh the chart after adding the drawing, and as the owner of the drawing.

    I have attached a very simple AddOn/Indicator to demonstrate the issue.

    Replication Steps:
    1. Import AddOn.
    2. Open chart.
    3. Add "Test_Indicator" to chart.
    4. Press "Create Drawing" button in add-on panel .
    5. Right click on chart and select "Reload All Historical Data" from the context menu.


    You will see after doing this the drawing disappears and is not redrawn.
    This also happens when a data connection is made too. Like if you create the drawing using the Create Drawing button before NT connects to its data source, then when it does the drawing will disappear.

    This behavior does not happen with user drawn chart objects. If you follow the steps above, but instead of creating the drawing using the AddOn button, you use the X Region drawing tool, the drawing does not disappear.

    How can I prevent drawings created with the AddOn from disappearing when the chart data is reloaded.

    Thanks for your time.
    Attached Files
    Last edited by codeowl; 01-14-2017, 01:53 AM. Reason: Added some more detail

    #2
    Hello codeowl,

    As a chart is reloaded, any indicators added to the chart would recalculate and then re-draw the drawing objects.
    Any manually drawn objects are saved by the NinjaTrader core and then redrawn.

    In your addon, you would need to detect that the chart was reloaded and then re-draw the drawing objects.
    I'm not aware of any trigger or flag that would detect this, however, you may keep a collection of the drawing objects in the addon and check with a timer to see if these are still on the chart.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ChelseaB,

      Thanks for the response mate. Instead of a timer, what about if I just put some code in the OnStateChange event of the indicator.
      I have done a test and when I do a reload of historical data or disconnect and reconnect to a datasource the following two states get raised in the following order:

      DataLoaded - All data series have been loaded
      Transition - Finished processing historical data

      Would there be an advantage to redrawing my drawings in one of these states over the other?

      I was thinking DataLoaded as it happens first, is there any reason I should use Transition instead?

      Thanks for your time.
      Last edited by codeowl; 01-17-2017, 02:49 AM. Reason: fixed typo

      Comment


        #4
        Hi codeowl,

        I'm not certain that I understand. Are you moving all drawing to an indicator?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GLFX005, Today, 03:23 AM
        0 responses
        1 view
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        14 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        3 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X