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

Control Strategy Parameters in SidePanel

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

    Control Strategy Parameters in SidePanel

    Hello,

    I'm trying to find a way to control the parameters of my strategy (specifically, TargetTicks and StopTicks) from the chart while the strategy is active.

    It's been successful to an extent where I've added Buttons for OnOff , LongOnly, ShortOnly, and ExitPosition in a SidePanel using the "ChartCustomSidePanelExample.zip" and it's been working great. But I'm pretty lost when it comes to adding a configurable integer in one of the rows in the SidePanel and linking it to TargetTicks and StopTicks.

    Can this be done in the SidePanel? If not, then what needs to be done to achieve it?

    Thanks.

    #2
    Hello KINGKODA,

    To confirm, the panel and buttons are added by the strategy that is also placing the orders, is this correct?

    In the button's .Click event handler method, set the TargetTicks value.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Yes the panel and buttons are added by the strategy that is also placing the orders.

      I don't understand what you mean by "In the button's .Click event handler method, set the TargetTicks value."

      If I add a new button for TargetTicks, how can I increase or decrease the number of ticks? Would that be done through separate buttons, say IncreaseTargetTicks and another button for DecreaseTargetTicks? Or is there a way to change TargetTicks without using two buttons?

      Comment


        #4
        Hello KINGKODA,

        Thank you for the reply.

        If you have added a new button for TargetTicks, you should have also added an event handler for that buttons Click event. The event handler is what is called when you click the button, or is what logic will occur when you click it. This is what Chelsea was referring to by
        "In the button's Click event handler method, set the TargetTicks value."
        Going back to your original post, I wanted to clarify are you actually trying to add buttons for this purpose or something like a text box? From your post, it was not clear except that you are asking how to add a GUI item that would let you configure this value.

        Using buttons would be one way to increment or decrement the value, so if buttons will work the solution is likely as simple as adding increment or decrement code to the buttons events. If you are using two buttons, the code will likely just require you to increment or decrement the value or TargetTicks++ or TargetTicks--.

        Code:
        private void MyButtonEventHandler(....)
        {
            TargetTicks++;
        }
        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          Thank you for explaining what Chelsea meant. To clarify, I wanted something like a text box that allows me to configure this value in the side panel. I haven't thought of adding two buttons until now.

          The goal is convenience, to change my target from 20 ticks to 60 ticks would require 40 clicks on the button. Is it possible to create something like a text box in the side panel so it doesn't take as much time?

          Thank you.

          Comment


            #6
            Hello KINGKODA,

            I just wanted to reply back briefly and let you know I am currently doing some research on this topic. Buttons are going to be easiest as that will just let you just click but as you noted a large amount would be cumbersome.

            A text input, or more specifically a quantity input here would be the best choice but a chart already has keyboard events which will interrupt. I am researching what would be the most suggestable way to prevent the charts instrument picker from appearing when trying to enter a value into the text box of your panel. Once I have more details surrounding what will be required here, I will reply back with more details.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Ok, Thank you Jesse.

              Comment


                #8
                Hello,

                I'm wondering if there's been any updates.

                Thank you

                Comment


                  #9
                  Hello KINGKODA,

                  At this time I don't have anything new to report, I am awaiting clarification from development in regard to the keyboard focus item I had noted.

                  You can utilize buttons for the time being if you wanted to get going with your project as you can always switch that with a text or number input later. We will need to wait for more information surrounding the keyboard and focus though as you would be unable to enter text into the box from the custom side panel. You can handle the keyboard events using the PreviewKey event handlers to avoid this but this is not generally a suggested item as there a lot of stipulations surrounding using that. Once I have more details I will reply back here.

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Okay I understand. Like you said I'll be using buttons for the time being.

                    Looking forward to new information.

                    Thank you very much..

                    Comment


                      #11
                      Hello KINGKODA,

                      Thank you for waiting, it looks like there is no internal method for controlling the focus so the suggested way to do this is still to use the preview key events to handle the keyboard events that you need.

                      There is an existing example of a text box being used from the UserControlCollection that demonstrates PreviewKey handling at the following link:


                      You would need to do something similar to handle each of the individual controls that need keyboard focus such as a text box or quantity picker.

                      You can find an example of a Quantity picker in the following link as well: https://ninjatrader.com/support/foru...191#post801191

                      I look forward to being of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by frankthearm, Today, 09:08 AM
                      5 responses
                      14 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      43 views
                      0 likes
                      Last Post jeronymite  
                      Started by yertle, Today, 08:38 AM
                      5 responses
                      16 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by adeelshahzad, Today, 03:54 AM
                      3 responses
                      19 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by bill2023, Yesterday, 08:51 AM
                      6 responses
                      27 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Working...
                      X