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

Chart intercepting AddOn Input

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

    Chart intercepting AddOn Input

    I have run into a problem with AddOns that seem a bit odd, not sure how to solve it. I have attached a sample project to show the problem.

    If you attach an AddOn to a chart (as per the attached project), the chart intercepts any input done in the AddOn.

    Instructions to Reproduce:
    • Unzip the attached file
    • Open the solution in VS2015
    • Compile the solution. It already copies the DLL to the correct place
    • Open NinjaTrader and open a new chart
    • Try and type something in the Addon's textbox


    To remove the AddOn again, just delete its DLL from My Documents\NinjaTrader 8\bin\Custom folder.

    Any ideas on how to solve this problem will be highly appreciated.
    Attached Files
    Last edited by JohnSteinberg; 05-01-2017, 05:40 AM.

    #2
    Hello JohnSteinberg,

    Thanks for opening the thread.

    We typically do not provide support or input for projects built outside of the NinjaScript Editor. I did have a look at your project anyway so I could provide further input.

    I see that your text box is conflicting with the chart's behavior to look switch instruments/intervals when you start typing within a chart. We have some sample code that demonstrates how an indicator can disable the Instrument changer in the case of a text box.

    Essentially, once State.Historical is reached, you can add a custom control that will allow you to update items created by the main UI thread.

    I have attached the sample code to help get you started.

    Please let me know if I may be of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Will try code

      Thanks for the quick reply Jim. I will try out the code and let you know how it goes.

      Comment


        #4
        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:	816
Size:	31.4 KB
ID:	1133396

        Comment


          #5
          Hello webus,

          the NumPad1 etc is part of the key enum, to convert that to a number representation you could try one of the solutions shown in the following public stackoverflow link: https://stackoverflow.com/a/769573

          Looking at it on my end it looks like the enum starts at 74 so you could likely just cast the key to an int and subtract 74, similar to whats being done in that stack overflow solution.
          Code:
          int code = (int)e.Key - 74;
          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Hi NinjaTrader_Jesse,

            Originally posted by NinjaTrader_Jesse View Post
            Hello webus,

            the NumPad1 etc is part of the key enum, to convert that to a number representation you could try one of the solutions shown in the following public stackoverflow link: https://stackoverflow.com/a/769573

            Looking at it on my end it looks like the enum starts at 74 so you could likely just cast the key to an int and subtract 74, similar to whats being done in that stack overflow solution.
            Code:
            int code = (int)e.Key - 74;
            I look forward to being of further assistance.
            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


              #7
              Hello webus,

              The example is showing just a text box so its intended purpose would be normal text. If you wanted to have a number entry you could look at using the NinjaTrader.Gui.Tools.QuantityUpDown control instead for a more number friendly control. The text box is just adding some text input and appended to the existing value with no sort of error checking or handing added. It looks like you have another post asking about the QuantityUpDown, you would likely be best off with that if you need only numbers.

              The existing code sample that Jim provided should be able to do what you are.asking however its not set up to input numbers or do anything special, that's really only intended to show how to make sure keyboard input works.

              To make this support numbers you would have to convert them when you set the textbox value so their not just a string.

              Code:
              textBoxSender.Text += e.Key.ToString(); // just a string



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

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post
                Hello webus,

                The example is showing just a text box so its intended purpose would be normal text. If you wanted to have a number entry you could look at using the NinjaTrader.Gui.Tools.QuantityUpDown control instead for a more number friendly control. The text box is just adding some text input and appended to the existing value with no sort of error checking or handing added. It looks like you have another post asking about the QuantityUpDown, you would likely be best off with that if you need only numbers.

                The existing code sample that Jim provided should be able to do what you are.asking however its not set up to input numbers or do anything special, that's really only intended to show how to make sure keyboard input works.

                To make this support numbers you would have to convert them when you set the textbox value so their not just a string.

                Code:
                textBoxSender.Text += e.Key.ToString(); // just a string



                I look forward to being of further assistance.
                Sorry, I have written not in my post.. My mistake.

                Comment


                  #9
                  I think I have a working fix

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by TraderBCL, Today, 04:38 AM
                  2 responses
                  14 views
                  0 likes
                  Last Post TraderBCL  
                  Started by martin70, 03-24-2023, 04:58 AM
                  14 responses
                  105 views
                  0 likes
                  Last Post martin70  
                  Started by Radano, 06-10-2021, 01:40 AM
                  19 responses
                  607 views
                  0 likes
                  Last Post Radano
                  by Radano
                   
                  Started by KenneGaray, Today, 03:48 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post KenneGaray  
                  Started by thanajo, 05-04-2021, 02:11 AM
                  4 responses
                  471 views
                  0 likes
                  Last Post tradingnasdaqprueba  
                  Working...
                  X