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

NinjaTrader.Gui.Tools.QuantityUpDown

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

    NinjaTrader.Gui.Tools.QuantityUpDown

    I added QuantityUpDown to the chart trader. When I try to change the value using the keyboard, the instrument input box pops up and I cannot change the QuantityUpDown value. What should I do?
    Please take a look:
    pic1: Here is the QuantityUpDown. I pressed the cursor into this field:
    Click image for larger version

Name:	Screenshot_1.jpg
Views:	1010
Size:	105.8 KB
ID:	1133350

    pic2: I press "5" on my keyboard:
    Click image for larger version

Name:	Screenshot_2.jpg
Views:	945
Size:	89.3 KB
ID:	1133351

    As you can see, the value in QuantityUpDown hasn't changed. Instead, a instrument selection window appeared. How can I solve this problem?


    Attached Files

    #2
    Hello webus, thanks for writing in.

    We have an example here on how to ignore the instrument selector when typing:
    https://ninjatrader.com/support/foru...put#post787406

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_ChrisL,

      Originally posted by NinjaTrader_ChrisL View Post
      Hello webus, thanks for writing in.

      We have an example here on how to ignore the instrument selector when typing:
      https://ninjatrader.com/support/foru...put#post787406

      Please let me know if I can assist any further.
      Sorry, I continued to write in a wrong post by mistake.

      1. Thank you! I'm halfway to a solution. When I click on the "numbers" keypad buttons, I get the words "NumPad1" and etc. How can I get real values and not "NumPad1"?
      Click image for larger version

Name:	Screenshot_3.jpg
Views:	835
Size:	31.4 KB
ID:	1133481

      2.I'm even closer to a solution. But more and more new problems arise. Here are a few:
      - I want to use this object for its intended purpose (the way it was created for). I want to enter a number into it and be able to edit it;
      - For example, I want to enter -152: How to do this?
      - For example, I entered -152 and want to correct it to +151: How to do it?

      Thanx!

      P.S.:
      It seems to me that this field should work much easier (automatically). Don't you think so?

      Comment


        #4
        Hello webus, thanks for your reply.

        The QuantityUpDown field was designed to take only positive values. To get the value of the quantity up/down selector you need to reference its Value property e.g. QuantityUpDownSelector.Value will return the set value.

        If you need positive and negative values you must add a text box like in the example I sent in my previous post. This will allow you to parse negative numbers. This type of WPF modification of the chart elements are not officially supported, so our documentation and support for these type of questions are limited.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi NinjaTrader_ChrisL,


          The QuantityUpDown field was designed to take only positive values.
          I think that you are not correct. Please take a look, I make negative values using arrows without any problem.:
          Click image for larger version  Name:	Screenshot_4.jpg Views:	0 Size:	5.5 KB ID:	1133694


          To get the value of the quantity up/down selector you need to reference its Value property e.g. QuantityUpDownSelector.Value will return the set value.
          I think that you don't see my problem. I know how to get the value that is contained in this object.
          My question is, how do I enter a value from the keyboard, for example: 1545?


          This type of WPF modification of the chart elements are not officially supported,
          Could you please clarify what you mean by "WPF"?

          Comment


            #6
            Hello webus, thanks for your reply.

            WPF is the GUI framework that is used to create the NInjaTrader 8 user interface. It is what you are using to add custom controls to the chart.

            Did you look at the example that I sent earlier? It shows how to get input from the keyboard. It shows you how to enter a value from the keyboard into a custom WPF control.

            Please let me know if I can assist any further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi NinjaTrader_ChrisL,

              Originally posted by NinjaTrader_ChrisL View Post
              WPF is the GUI framework that is used to create the NInjaTrader 8 user interface. It is what you are using to add custom controls to the chart.
              Got it!

              Did you look at the example that I sent earlier? It shows how to get input from the keyboard. It shows you how to enter a value from the keyboard into a custom WPF control.
              Yes, I even accidentally mixed up the forum threads and started writing in that post.
              Having tried your example, I ran into a problem that I also described in several letters above (here #3). Typing characters on the keyboard, I get the button codes (for example, "Num6" instead of "6"). In order to fully understand my problem - could you run your example and try to type a number, for example "1562", and then try to change it to "1523" - you will immediately understand what I mean. This window does not work as it should. I cannot enter numbers into it (since the callback catches the keycodes of the keyboard).

              Last edited by webus; 12-24-2020, 11:36 AM.

              Comment


                #8
                Hello webus, thanks for your reply.

                This "D#" format is the only format that PreviewKeyDown will give for the character, so the correct information needs to be parsed from the string e.g. mystring[1] would be the value of the key being pressed. I apologize but I can not give an exact example because this falls into a general C# category and not focused on NinjaScript. You can manipulate strings in C# in many different ways so there is a lot of flexibility there, see the documentation page for detailed descriptions:
                https://docs.microsoft.com/en-us/dot...g?view=net-5.0

                Best regards,
                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi NinjaTrader_ChrisL,

                  Originally posted by NinjaTrader_ChrisL View Post
                  Hello webus, thanks for your reply.

                  This "D#" format is the only format that PreviewKeyDown will give for the character, so the correct information needs to be parsed from the string e.g. mystring[1] would be the value of the key being pressed. I apologize but I can not give an exact example because this falls into a general C# category and not focused on NinjaScript. You can manipulate strings in C# in many different ways so there is a lot of flexibility there, see the documentation page for detailed descriptions:
                  https://docs.microsoft.com/en-us/dot...g?view=net-5.0

                  Best regards,
                  -ChrisL
                  So, in other words, QuantityUpDown (NinjaTrader.Gui.Tools.QuantityUpDown) works correctly and this is OK that I cann't just type in integer values, use "delete" and "backspace" for editing in PreviewKeyDown, am I right? If I'm right - that's so cute.

                  Comment


                    #10
                    Hello webus,

                    This is Jim responding on behalf of Chris who is out of the office at this time.

                    Everything is working correctly. If you are adding controls to a chart/ChartTrader, you will have to workaround the Overlay Instrument Selector and parse e.Key as seen in the example linked in post #2 to handle backspaces and deleting.

                    Please let us know if you have any additional questions.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Hi NinjaTrader_Jim,
                      Originally posted by NinjaTrader_Jim View Post
                      Hello webus,

                      This is Jim responding on behalf of Chris who is out of the office at this time.

                      Everything is working correctly. If you are adding controls to a chart/ChartTrader, you will have to workaround the Overlay Instrument Selector and parse e.Key as seen in the example linked in post #2 to handle backspaces and deleting.

                      Please let us know if you have any additional questions.
                      Maybe I dont understand what you mean by "Everything is working correctly", but in my oppinion everything will work correctly when I just add the "PreviewKeyDown" object to the chart and just enter any value from the keyboard and just take this value programmatically. Are we on the same page in this?

                      to handle backspaces and deleting.
                      When I press a button on the keyboard, I get the CODE of the key, not its value. So when I click on "delete" button, I will get the "delete" button code.
                      How does this help me to delete the entered value?
                      What if two or three numbers are highlighted and I only need to delete those numbers (for example, in the number "154723" I selected "47" and I want to delete them to get "1523")?
                      Have you tried your example from #2 yourself? Am I right if I say that you are telling me to develop all the logic for working and processing numbers and pressing the "delete" and "backspace" keys?

                      Comment


                        #12
                        Hello webus, thanks for your reply.

                        The best example to reference is the "Text" drawing tool under the Drawing Tools folder. This handles the system keys and appends the proper text to the TextBox object with PreviewKeyDown. The implementation starts at line 385 of that script.

                        Please let me know if I can assist any further.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          NinjaTrader_ChrisL,

                          Originally posted by NinjaTrader_ChrisL View Post
                          Hello webus, thanks for your reply.

                          The best example to reference is the "Text" drawing tool under the Drawing Tools folder. This handles the system keys and appends the proper text to the TextBox object with PreviewKeyDown. The implementation starts at line 385 of that script.

                          Please let me know if I can assist any further.
                          Unfortunately, your answer is not relevant to my request. I cannot apply TextBox to QuantityUpDown.
                          Can't we simplify the task? The platform contains ready-made options, could you please send me the code for a ready-made solution for QuantityUpDown? For example, QuantityUpDown is used in an ATM when setting StopLoss and TakeProfit. Could you please send me this code? Please take a look:
                          Click image for larger version

Name:	Screenshot_5.jpg
Views:	808
Size:	42.0 KB
ID:	1134229


                          Comment


                            #14
                            Hello webus, thanks for your reply.

                            In a stand-alone addon, the QuantityUpDown selector will work just fine, but the issue here is you are adding the text box to a chart. In this case, you must follow the examples laid out in the Text drawing tool to get around the instrument selector input. Please review this script, in particular, the implementation of the PreviewKeyDown event.

                            Please let me know if I can assist any further.

                            Chris L.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChrisL View Post
                              Hello webus, thanks for your reply.

                              The best example to reference is the "Text" drawing tool under the Drawing Tools folder. This handles the system keys and appends the proper text to the TextBox object with PreviewKeyDown. The implementation starts at line 385 of that script.

                              Please let me know if I can assist any further.
                              I'll have a look at this thanks in relation to my other question
                              https://ninjatrader.com/support/foru...35#post1190335

                              Meanwhile the @Text.cs code (from local path C:\Users\<YOUR User Name>\Documents\NinjaTrader 8\bin\Custom\DrawingTools)
                              C:\Users\\Documents\NinjaTrader 8\bin\Custom\DrawingTools reference: https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/1133348-ninjatrader-gui-tools-quantityupdown?p=1134134#post1134134

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by frankthearm, Yesterday, 09:08 AM
                              11 responses
                              41 views
                              0 likes
                              Last Post frankthearm  
                              Started by junkone, Today, 11:37 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post junkone
                              by junkone
                               
                              Started by quantismo, 04-17-2024, 05:13 PM
                              5 responses
                              35 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by proptrade13, Today, 11:06 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              34 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X