• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Voice Commands to ChartTrader

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

    Voice Commands to ChartTrader

    Hello,

    (Disclaimer: Not supported code by NinjaTrader)

    I am in the process of coding an indicator to provide voice commands (via headset mic) to ChartTrader (indicator). I don't like using the mouse actually, to make trades.

    (I am using C# code snippets I found on the web)

    Even without custom code, one can navigate and push buttons on Ninja Trader, under Windows 8, with Voice Recognition on...but it does not work well for several reasons. Thus this effort so I have full control over what happens.

    It works! You can verify by loading it on a chart and opening the Output window. Then talking into the mic.

    Voice Commands that it recognizes (these are not linked to actions in ChartTrader at the moment. This code is just to recognize the words.

    LONG MARKET / BID / ASK (three different commands)
    SHORT MARKET / LONG /ASK
    REVERSE
    GET OUT
    TOGGLE OCO

    and any others you might want.

    But there are two issues to solve that perhaps a C# guru can fix.

    Attached is the .cs file. You will need to install the Voice Recognition components of .NET 3.5 and then set up references them in NinjaTrader code editor.

    1) the indicator will process the voice command only once. then I have to reload the indicator before it will listen again

    2) the indicator is actively listening even if the chart it is on is not in focus....it needs to only listen when the panel/chart it is on is in focus so that it does not process commands when the user is not looking at the chart
    Attached Files

    #2
    Hello TurtleTrader,

    1) Are you disposing the VoiceCommand appropriately, meaning at the right time or placement in the script? I am not familiar with the Voice Recognition components

    2) There are some Windows Forms commands to check if the parent window for the indicator is focused or not. You could potentially use these to check that and then use the Voice Commands
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      one solved

      Hi Cal,

      I found one solution....this is working to keep it listening

      private void RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
      {
      listener.RecognizeAsync();
      Print (" Completed");
      }

      now I need to find a way to know when the chart is active .... then I will try to start and stop the listnerer thread. I'll start the thread when the chart has focus and stop it when the chart looses focus...but so far I'm not having luck with the GOTFOCUS and LOSTFOCUS events for ChartControl.

      Thank you.

      Comment


        #4
        focus

        ok, this is giving me the change in focus

        ChartControl.ChartPanel.GotFocus += new EventHandler (ThisGotFocus);
        ChartControl.ChartPanel.LostFocus += new EventHandler (ThisLostFocus);

        but, now I'm not sure about starting a Thread (for the voice recognition) inside Ninja, if it is going to cause problems.

        Because it seems when I press F5 (to reload the indicator) the existing thread is not terminated and a duplicate is started...not sure but it seems to be this way, and if so this is going to cause problems.

        Yes, of course, this is beyond Ninja support, but perhaps a C# guru will know.

        Thank you.

        Comment


          #5
          Originally posted by Turtle Trader View Post
          ok, this is giving me the change in focus

          ChartControl.ChartPanel.GotFocus += new EventHandler (ThisGotFocus);
          ChartControl.ChartPanel.LostFocus += new EventHandler (ThisLostFocus);

          but, now I'm not sure about starting a Thread (for the voice recognition) inside Ninja, if it is going to cause problems.

          Because it seems when I press F5 (to reload the indicator) the existing thread is not terminated and a duplicate is started...not sure but it seems to be this way, and if so this is going to cause problems.

          Yes, of course, this is beyond Ninja support, but perhaps a C# guru will know.

          Thank you.
          Where are you removing the EventHandlers that you are adding here?

          Comment


            #6
            reply

            they are removed in OnTermination

            I now have it working the way I want...the skeleton code is attached, this is for coders and is not a finished product

            the code will only process voice commands when the chart the indicator is on has focus

            this way the indicator can be on multiple charts and the voice recognition only processes on the chart that has focus

            others can now integrate it with their code

            any bugs in the code please let me know...I'm not a C# guru
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by MarthaClines, Yesterday, 06:20 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by danitralla, Today, 01:23 AM
            2 responses
            37 views
            0 likes
            Last Post NinjaTrader_DrewO  
            Started by Longhornmark, Today, 06:52 AM
            0 responses
            2 views
            0 likes
            Last Post Longhornmark  
            Started by Steve L, Yesterday, 10:01 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by reedstickets, 05-24-2019, 07:53 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Jim  
            Working...
            X