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

Can global draw object be updated from code?

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

    Can global draw object be updated from code?

    Hello,

    A few years ago I made an indicator that adds a toolbar to change the properties of draw objects. Color, size, style of line etc. It had the limitation of only updating objects within the chart. Changes made to global objects would not be reflected in other charts, only the chart the change was made. I managed to find a workaround that applied changes globally, but some of the changes only applied if the object was moved around in the chart. Thus triggering a position update would force all charts to notice the change in color, size etc.

    Has NinjaTrader8 added an official method to update the properties of global objects from code?

    Best regards,

    Unsuitable
    Ocean Trading Indicators
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable,

    Thank you for your post.

    The behavior is still set to only make the change on the chart where the script is applied; for example, if you use the foreach loop in the "Looping through the collection to find specific draw objects" example from this page within an indicator, the global lines will change to Brushes.Black only on the charts where the indicator is applied:


    If you are working with NinjaScript-drawn objects, in order to make a change that takes place globally you could save the object's properties, then call RemoveDrawObject(), then finally re-draw the desired object with the desired properties. This would replace the object with a new one drawn programmatically and the properties would be put into place globally.
    Otherwise, if you are working with a toolbar that detects user-drawn objects and wants to make a change, as a workaround you could set the IsVisible property to false for the user-drawn objects (this just sets them to be removed from charts visually, but they would still exist and be listed in the Drawing Tools window) and then re-draw the object programmatically so that the properties are put into place globally. For each desired change via either approach, you could then RemoveDrawObject() for any NinjaScript-drawn objects and replace them with a new one that has the change in property (or properties). For more information:



    You could determine if IsVisible needs to be set to false if IsUserDrawn is true:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hello Emily,

      In this case, the objects are drawn by the user or using the regular tools. So the draw object would be attached to the chart and not the indicator.

      It sounds like an official way to call a refresh of globally drawn objects has not been added yet. Could you add a vote for a "Force Refresh of Global Objects" feature (or whatever it would be called)?

      Best regards,

      Unsuitable
      Ocean Trading Indicators
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Originally posted by Unsuitable View Post
        Hello Emily,

        In this case, the objects are drawn by the user or using the regular tools. So the draw object would be attached to the chart and not the indicator.

        It sounds like an official way to call a refresh of globally drawn objects has not been added yet. Could you add a vote for a "Force Refresh of Global Objects" feature (or whatever it would be called)?

        Best regards,

        Unsuitable
        Ocean Trading Indicators
        Thanks for your feedback.

        I have submitted your interest in this feature request to the Development Team and will follow up with the internal tracking number for your reference as soon as it is created (or as soon as your vote is added in the case that this is an existing request).

        Thanks in advance for your patience.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          For reference, I did come up with a solution to update objects globally. The indicator cycles through all available chart windows, then tabs, and then tag IDs. If it finds a match it updates the properties. That's a lot of back and forth from an indicator perspective. Also, the changes are only partially made, pressing F5 resets the global object to its original state. Whatever the internal global collection of objects is did not accept or see the change, only the charts' visual components.

          Ideally, Ninja would have a list of global objects and any changes made by an indicator would automatically trigger an update. Or Ninja would have a ForceGlobalRefresh() method. That could be inefficient. Perhaps in conjunction with a global draw object collection list, the code would call onto all draw objects of it self to update its containing charts. Which would look like the following

          Code:
          if (objectReference.IsGlobalDrawingTool)
            objectReference.GlobalForceUpdate(); --> All draw objects of that reference find its containing chart and update its changes.
          
          Alternatively, simply the method only without checking if it is global first. The method itself will check for that. If it's not is will skip over the method and continue with the rest of the code
          objectReference.GlobalForceUpdate();
          Anyway, those are some ideas.
          Unsuitable
          NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

          Comment


            #6
            Hello Unsuitable,

            Thanks for your patience and the other ideas..

            Your vote has been added to the feature request with ID SFT-4438. Please reference this internal tracking number when contacting Platform Support if you ever have questions regarding this feature request.

            When a feature request is implemented, you'll find a description of the new feature in the release notes:Thank you for using NinjaTrader.​
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,406 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            98 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            8 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            160 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            9 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X