NexusFi: Find Your Edge


Home Menu

 





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 4,536 views
    2. thumb_up 4 thanks given
    3. group 0 followers
    1. forum 13 posts
    2. attach_file 0 attachments




 
Search this Thread

SetActiveWindow in NT

  #1 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515

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

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,603




Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090


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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515

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
  #6 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090

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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515


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
Thanked by:
  #8 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090

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 NexusFi Trade Journal Reply With Quote
  #9 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515

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

Started this thread Reply With Quote
  #10 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090


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 NexusFi Trade Journal Reply With Quote




Last Updated on December 3, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts