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

Managing Strategy from Custom UI or Add On

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

    Managing Strategy from Custom UI or Add On

    Hi,

    I would like to manage my strategy from custom UI or AddOn. I would like to change the params / enable / disable / add strategy from this custom UI or add-on. Is that possible ? if so how to achieve this ?

    #2
    Hello nandhumca,

    Yes that is possible, the most simple way would be to add UI elements to the chart window. You can find some samples of modifying the window in the link below. Another approach would be to design your own custom window using an NTWindow and then have the strategy launch the window. That is a little more complex and assumes you have some background in WPF development and object oriented programming as you would need to design the window and its controls/events yourself and also pass an instance of the strategy to the window when it is launched. If you wanted more details about a custom window I can try to locate some relevant resources on that and provide a more detailed description in a follow up post.

    Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've


    As a side note you wouldn't be able to physically enable a strategy using an addon or custom controls but you can enable/disable the strategies trading logic while leaving it running to accomplish that type of task. Another option is to not use a strategy and instead use an indicator which stays applied to a chart, an indicator can also place trades in realtime using the addon framework but that type of script cannot be backtested.
    Last edited by NinjaTrader_Jesse; 04-05-2024, 12:12 PM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. So from UI , I can add an strategy to control pane strategy window, right. What Api needs to be called add or remove a strategy instance to and from strategy panel? If there are any references code, it will be helpful.

      Kindly share more details and resources for WPF also. I have used oops.

      Comment


        #4
        Hello nandhumca,

        There is no APi to add or remove strategy instances, that is a manual step. You can have a strategy terminate based on conditions by using CloseStrategy



        For WPF we suggest using external WPF tutorials for C# WPF development. The samples that I had linked to show how to integrate WPF controls with NinjaTrader, beyond that all that would be required is learning about the WPF framework which there are many tutorials for online.

        Learn about the unified programming model in Windows Presentation Foundation (WPF) for building line-of-business desktop applications in Windows.
        JesseNinjaTrader Customer Service

        Comment


          #5
          In my use case, i have added 40+ strategy instance of same strategy in control panel directly without chart. When I want to change the instrument while do playback or change one property value in all 40+ strategies, it is very time consuming and there is a high possibilities for me to miss to set the value. Is there any way to change access all the strategies added in control panel and change the property of each ?

          Comment


            #6
            Hello nandhumca,

            Are all of the strategies running on the same account? If so you could use the addon account class strategies collection. If the strategies are on different accounts it would require using different code to find the accounts. You would need to have 40 account variables and find 40 accounts if you were using 40 different accounts as an example.



            You could make a public property or method in the strategy and then cast the strategy in the strategies collection to your custom strategies type to use that property or method.

            Code:
            [XmlIgnore]
            [Browsable(false)]
            public int MyPublicProperty { get; set; }
            Then in the addon using the sample from the help guide link:

            Code:
            MyCustomStrategiesType variableName = strategy as MyCustomStrategiesType;
            variableName.MyPublicProperty = 1;
            or 
            variableName.MyCustomMethod();
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks. all the strategies for single account. I primarily want to change the Account when I my daily profit reached some threshold for one account. Also I want to change the instrument on all 40+ strategies when I do playback.

              Comment


                #8
                Hello nandhumca,

                The instrument would be something you need to change by re applying the strategy, there is not a way to change the data series parameters in the strategies properties.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by aligator, 01-06-2022, 12:14 PM
                4 responses
                233 views
                0 likes
                Last Post john_44573  
                Started by reynoldsn, Today, 05:56 PM
                0 responses
                5 views
                0 likes
                Last Post reynoldsn  
                Started by bortz, 11-06-2023, 08:04 AM
                51 responses
                1,989 views
                0 likes
                Last Post aligator  
                Started by dmking, 11-12-2019, 12:31 PM
                4 responses
                4,150 views
                0 likes
                Last Post jasonw
                by jasonw
                 
                Started by roblogic, Today, 04:31 PM
                0 responses
                10 views
                0 likes
                Last Post roblogic  
                Working...
                X