SetActiveWindow in NT - futures io
futures io



SetActiveWindow in NT


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one redratsal with 6 posts (3 thanks)
    2. looks_two terratec with 5 posts (1 thanks)
    3. looks_3 Big Mike with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,011 views
    2. thumb_up 4 thanks given
    3. group 0 followers
    1. forum 13 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

SetActiveWindow in NT

(login for full post details)
  #1 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 515 received

If working with HotKeys in NT you have the problem that some of them need the window to be active. If you fire a market order then it goes to the active window. If you have (HotKey) code in a non active window it will not be executed.

How can I set a window a moment before execution to active in NT?

Something like:

SetActiveWindow()
SendKeys.Send("^%{LEFT}"); // for market order

But of course it is not that simple. What I found in the WWW was confusing and not very simple.

Has someone a code for NT?

Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(79 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(23 thanks from 5 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(15 thanks from 8 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Rogue MNQ 2/21 Journeyby RogueJoules
(0 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
71 thanks
Would You Sell Your System?
65 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
30 thanks
Big Mike in Ecuador
25 thanks
 
(login for full post details)
  #3 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 49,960 since Jun 2009
Thanks: 32,433 given, 98,154 received




Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received


terratec View Post
If working with HotKeys in NT you have the problem that some of them need the window to be active. If you fire a market order then it goes to the active window. If you have (HotKey) code in a non active window it will not be executed.

How can I set a window a moment before execution to active in NT?

Something like:

SetActiveWindow()
SendKeys.Send("^%{LEFT}"); // for market order

But of course it is not that simple. What I found in the WWW was confusing and not very simple.

Has someone a code for NT?

NT Hotkeys are quite basic and limited, why don't you use an external app like autohotkey AutoHotkey - Free Mouse and Keyboard Macro Program with Hotkeys and AutoText Some pictures and more explanations would help to define the problem. I am currently using AHK find some examples here

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to redratsal for this post:
 
(login for full post details)
  #5 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 515 received

I set an entry order by pushing a button in an indicator (as always not strategy) one tick above the close of the last bar. Then the entry is trailed if the next bar's high is lower. If it get triggered a hotkey does send a MIT order with the active ATM strategy.

Problem: The code does only execute the hotkey when the window is active (that's by NT) So I have to set it active before the hotkey code is executed.

@redratsal: thanks for the AutoHotKey link. I will check it. If I can call AutoHotKey from the NT code it could work.

Started this thread Reply With Quote
 
(login for full post details)
  #6 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received

This is an example how you could use AHK integrated with NT Hot Key:

1) I set in NT my market buy order with the keys ALT+F12
2) I set my Activation Window with AHK with the keys ALT+F11

Everytime you have the trigger all you have to do is push ALT+F11+F12



AHK script

 
Code
!F11::
WinWait, 6E 12-11 , 
IfWinNotActive, 6E 12-11   , , WinActivate, 6E 12-11 , 
WinWaitActive, 6E 12-11 , 
return

IfWinActive [, WinTitle, WinText, ExcludeTitle, ExcludeText]

**you will have to specify the name of the window you want to activate, in my case 6E 12-11**

Visit my futures io Trade Journal Reply With Quote
The following 2 users say Thank You to redratsal for this post:
 
(login for full post details)
  #7 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 515 received


redratsal View Post
Some pictures and more explanations would help to define the problem.

In the meantime I did post the related indicator here.

Started this thread Reply With Quote
The following user says Thank You to terratec for this post:
 
(login for full post details)
  #8 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received

With AHK all you have to do is insert the AHK shortcut before your NT shortcut string:


//if (entryprice*TickSize>=GetCurrentBid())
else if (entryprice*TickSize>=Low[0])
{
SendKeys.Send("AHK keys");
SendKeys.Send("^%{RIGHT}");
entryprice=0;
}

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #9 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 515 received

@redratsal:
My thinkung did go in the same direction. Will do over the weekend. THX

Started this thread Reply With Quote
 
(login for full post details)
  #10 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received


Another solution is via c#, I haven't tested it yet but you can look here (if you haven't already done it):

Activated Event

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #11 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received

Activate window, close window, bring window to front : WindowWindows Presentation FoundationC# / CSharp Tutorial

this is the part that should interest you:

 
Code
 private void btnBringToFront_Click(object sender, RoutedEventArgs e)
        {
            Window window = lbxWindows.SelectedItem as Window;

            if (window != null)
                window.Activate();
        }

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #12 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 515 received


redratsal View Post
Another solution is via c#, I haven't tested it yet but you can look here (if you haven't already done it):

Activated Event

C# would be my preferred way. But it needs more programming skills than I have… I am working on it.

Started this thread Reply With Quote
 
(login for full post details)
  #13 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received


terratec View Post
C# would be my preferred way. But it needs more programming skills than I have… I am working on it.

The problem with c# is with the name of the window, you will have to match the exact name, that means if you change the contract of your instrument you will have to remember to change, in the code, the new name of your window. With AHK you do not need to match the exact name you can set any character starting with; for example 6E and that makes things easier to handle.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #14 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 49,960 since Jun 2009
Thanks: 32,433 given, 98,154 received

You can get the full instrument name with Instrument.MasterInstrument.Name or something like this (been too long). It would include the expiration, or if not there is another option for .Expiry or similar. Point is, you should be able to determine any NT-generated window title name.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > SetActiveWindow in NT


Last Updated on December 3, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts