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

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


              #7
              [QUOTE=Turtle Trader;n639109]reply

              Hi, did you ar anyone brought it to work? Voice Commands on NT8 would be just fantastic! I just found a cTrader version https://clickalgo.com/voice-recognition-trading...

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by AttiM, 02-14-2024, 05:20 PM
              11 responses
              184 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by fernandobr, Today, 09:11 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by timmbbo, Today, 08:59 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by KennyK, 05-29-2017, 02:02 AM
              2 responses
              1,281 views
              0 likes
              Last Post marcus2300  
              Started by itrader46, Today, 09:04 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Working...
              X