Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Key intercept

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

    Key intercept

    Hello,

    I'm trying to intercept key signals from my strategy class.
    I know that a PreviewKeyDown event needs to be handled to intercept a key, but the Strategy class does not have that. What class in NT8 has a PreviewKeyDown event that I can handle, that is executed when a strategy is running and a key on the keyboard is pressed? I'm guessing it would need to be some global class with a GUI or GUI handling.

    V/R,
    --Maxim

    #2
    DieSlower, Maxim, PreviewKeyDown is a C# WPF Event. It is not NinjaScript-specific. If you search the Internet for "C# WPF PreviewKeyDown", that should point you to useful material.

    The basic principle is straightforward: associate the event handling method for PreviewKeyDown that you write with the control you want to monitor.

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    Comment


      #3
      jeronymite Correct, I know it's part of the .net framework like .ToString(), but as I mentioned not all classes have access to it, so the question it which classes that are accessible from a strategy class do, and which can be assigned a handler from a strategy. It depends on NT8 class structure and design, hence the question.

      Comment


        #4
        Hello DieSlower,

        Thank you for your post.

        You can find a sample of using PreviewKey events in a strategy attached below. This strategy will print "keys pressed" to the NinjaScript Output window when CTRL + SHIFT + 2 is pressed.

        As this is not NinjaScript specific you won't find much information about using WPF key events here on the forum or in the help guide. The best bet is to look for WPF samples online for specific concepts like this and then apply them in NinjaTrader.

        I look forward to being of further assistance.
        Attached Files
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thank you @NinjaTrader_Kate that works!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kujista, Today, 06:23 AM
          4 responses
          13 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by traderqz, Yesterday, 09:06 AM
          2 responses
          15 views
          0 likes
          Last Post traderqz  
          Started by traderqz, Today, 12:06 AM
          3 responses
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by RideMe, 04-07-2024, 04:54 PM
          5 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by f.saeidi, Today, 08:13 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X