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

Modifying Read-Only Properties of UI Elements for Custom Add-On Development

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

    Modifying Read-Only Properties of UI Elements for Custom Add-On Development

    Hello NinjaTrader Community,

    I'm currently working on developing a custom add-on for NinjaTrader and have encountered a situation where I need more control over certain UI elements than the platform seems to natively allow. Specifically, I'm looking to programmatically interact with button controls in a way that goes beyond the exposed methods and properties.

    One particular challenge is dealing with the IsPressed property of button elements, which, as per standard WPF behavior, is read-only. This property indicates whether the button is currently being pressed down by the user. My project requires a level of automation that simulates user interactions with these buttons, but without direct user input.

    I understand that modifying read-only properties or extending the default behavior of UI elements can lead to potential issues, including maintenance and compatibility concerns. However, my use case presents a unique requirement that I believe might necessitate such an approach.

    Could anyone provide guidance or share experience on the following points?
    1. Framework Extensibility: Does NinjaTrader offer any extensibility features or APIs that allow for more granular control over UI element properties, specifically for overriding or extending the behavior of read-only properties like IsPressed?
    2. Custom Control Development: Is it advisable or even possible within the NinjaTrader development environment to create custom controls that inherit from standard controls but offer extended functionality, such as a button control with a programmable IsPressed state?
    3. Best Practices: If anyone has tackled similar challenges, what are the recommended best practices to ensure that any such modifications maintain compatibility with NinjaTrader updates and adhere to sound software development principles?
    4. Alternative Approaches: If direct modification of read-only properties is not recommended or possible, what alternative approaches could be considered for simulating user interactions with UI elements in an automated manner?

    I appreciate any insights, suggestions, or references to documentation that the community or the NinjaTrader team can provide. My goal is to develop this add-on in a way that is both functional for my needs and respectful of the platform's design and ecosystem.

    Thank you in advance for your support and guidance.

    Best regards,

    Aviram Y.

    #2
    Hello Aviram,

    Thank you for your post.

    What kinds of UI elements are you looking to "interact" with, and what actions are you looking to trigger without a button being pressed? Are the buttons you refer to UI elements that come with NinjaTrader by default or are they buttons you have created? If you are not looking for a button press event to trigger the actions, what condition are you looking to have that triggers the actions for the buttons you refer to?

    WPF modifications can be made programmatically as demonstrated in this indicator script:


    There is an Add-On overview here, including a link to download "AddOn Framework NinjaScript Basic" that you may import to your platform and review how the addon window was created. You can then make edits to that script and test out the results to get an idea of how different parts of the script affect the UI elements that are added to the addon window:


    I look forward to your reply.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thank you for your response and for providing these resources.

      The UI elements I'm aiming to interact with are primarily the buttons within the NinjaTrader UI, specifically those that are part of the import process for NinjaScript add-ons. My objective is to automate certain interactions with these buttons to streamline the import process, especially when dealing with a large number of add-ons. This includes both default buttons provided by NinjaTrader and custom buttons that are part of the add-ons being imported.

      The primary action I'm looking to automate is the confirmation of script overrides during the import process. Currently, this requires manual confirmation for each script, which is time-consuming and prone to errors, especially when importing add-ons that reference default indicators like @SMA.cs and @MACD.cs.

      Ideally, I'd like to implement a "Yes to All" functionality for overriding scripts that do not include default indicators (indicated by the "@" prefix in their names), while skipping or handling with caution any scripts that modify default indicators to prevent import errors.

      I've reviewed the resources you've provided, and they offer valuable insights into creating and modifying WPF elements within NinjaTrader. However, my challenge lies more in interacting with existing NinjaTrader UI elements in a way that isn't directly supported through the standard NinjaScript APIs.

      Based on this, I have a few specific questions:
      1. Extending Default UI Behavior: Is there a supported way to extend or modify the behavior of NinjaTrader's default UI elements, such as adding a "Yes to All" button to the script override confirmation dialog during imports?
      2. Automation Within NinjaTrader's UI: For tasks that involve interacting with NinjaTrader's default UI elements (like button clicks), are there recommended approaches or best practices within the NinjaTrader ecosystem, or is external automation (e.g., using UI automation tools) the only viable route?
      3. Handling Conflicts with Default Indicators: When automating the import process, is there a recommended approach for identifying and handling scripts that might conflict with default indicators, to avoid the import errors that occur when inadvertently attempting to override these default scripts?
      Note on Default Indicators:

      The reason I frequently encounter default indicators like @SMA.cs and @MACD.cs during the import process is due to their references and usage within the custom add-ons/strategies I'm importing. Many of these add-ons extend or build upon the functionality of NinjaTrader's default indicators, incorporating them as foundational elements within their own logic. While I understand the necessity of referencing these default indicators, this aspect of the import process often leads to the aforementioned errors. Each time a script that references a default indicator is imported, NinjaTrader prompts for confirmation to override the existing script, even when the intention is merely to reference, not modify, the default indicator. This necessitates manually selecting 'No' for each such instance to avoid errors, which is both time-consuming and error-prone. Automating this part of the process, while ensuring that actual modifications to default indicators are handled with care, would significantly streamline addon imports and reduce the potential for errors.


      Your guidance on these points would be incredibly valuable as I navigate the best approach to automating this aspect of my workflow within NinjaTrader.

      Thank you for your continued support.

      Best regards,

      Aviram

      Comment


        #4
        Hello Aviram,

        Thank you for your reply.

        I appreciate the additional details and information; it helps me to better understand and address your inquiry. I have included answers to your questions below:
        1. Extending Default UI Behavior: Is there a supported way to extend or modify the behavior of NinjaTrader's default UI elements, such as adding a "Yes to All" button to the script override confirmation dialog during imports?
          • No, modifying the default behavior of NinjaTrader's UI is not supported. You may be able to find ways to do so, though this is undocumented/unsupported and should only be done at your own risk. Because it is unsupported, behaviors are subject to change at any time with future releases of NinjaTrader and results may vary.
        2. Automation Within NinjaTrader's UI: For tasks that involve interacting with NinjaTrader's default UI elements (like button clicks), are there recommended approaches or best practices within the NinjaTrader ecosystem, or is external automation (e.g., using UI automation tools) the only viable route?
          • This starts to branch outside of the scope of NinjaTrader support. There are ways to use tools, such as the Microsoft Inspect tool, to identify Automation IDs that could be used programmatically. This process is not documented in the help guide and is therefore unsupported, though further information has been discussed in other forum threads such as the following:
          • https://forum.ninjatrader.com/forum/...t=7#post752775
        3. Handling Conflicts with Default Indicators: When automating the import process, is there a recommended approach for identifying and handling scripts that might conflict with default indicators, to avoid the import errors that occur when inadvertently attempting to override these default scripts?
          • Rather than modifying NinjaTrader's UI to automate the import process, which does not have a native way to select "Yes to all" for the system script prompts, you could consider creating a custom installer to import your scripts. Creating a custom installer also goes beyond the support offered by NinjaTrader, though you could use third-party resources to look into this option. The installer would need to place any .cs or .dll files into the appropriate directory within the NinjaTrader 8 folder and it would also potentially need to append any references to the Config.xml file found in the Documents\NinjaTrader 8\ directory. The Control Center > Tools > Import > NinjaScript AddOn process already adds the necessary references to the Config.xml file as part of its process; this is the same idea as right-clicking the NinjaScript Editor window > selecting References > adding/removing references.
        Please let us know if we may be of further assistance.

        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          Thank you very much for your comprehensive response and for shedding light on the possibilities and limitations within the NinjaTrader platform regarding UI modifications and automation.

          I understand and appreciate the caution advised against making unsupported modifications to the NinjaTrader UI. The insights provided regarding the use of external tools for UI automation, albeit unsupported, and the suggestion to explore a custom installer approach are particularly valuable. These avenues present interesting possibilities for addressing my automation needs while being mindful of the stability and integrity of the trading platform.

          The reference to the forum thread and the discussion around using tools like the Microsoft Inspect tool for identifying Automation IDs offer a good starting point for further exploration. I will proceed with caution and keep the unsupported nature of these approaches in mind.

          The idea of developing a custom installer to manage script imports more efficiently is intriguing and seems like a promising solution that aligns better with supported practices. I will certainly explore this option further and leverage third-party resources to understand the intricacies involved in creating such an installer.

          I appreciate the time and effort taken to address my queries. Your guidance has been instrumental in helping me navigate my options and has provided a clearer path forward.

          Please extend my thanks to the team for their support and for maintaining an open and helpful forum for NinjaTrader users. I look forward to continuing to be a part of this vibrant community.

          Best regards,

          Aviram

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          17 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          5 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,408 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Working...
          X