NT8 send keys - NinjaTrader | futures io social day trading
futures io futures trading


NT8 send keys
Updated: Views / Replies:408 / 7
Created: by b16aln Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

NT8 send keys

  #1 (permalink)
London
 
Trading Experience: None
Platform: ninjatrader
Favorite Futures: ftse100
 
Posts: 36 since Sep 2017
Thanks: 7 given, 6 received

NT8 send keys

Hi,

I'm looking to implement use of send keys in my script to automatically do a one off duplicate in new tab when an event occurs. So i will be using send keys method to submit my "dupicate in new tab" hot key;

if(event logic)
{
event logic=false // to stop unlimited duplications
System.Windows.Forms.Sendkeys.SendWait(insert duplicate in new tab hotkey e.g ctrl + a, "^a");
}

I'm getting some unexpected action in that the first instance of the method getting actioned, it opens the search function on the chart as if the letter (a) part of the hitkey only has been pressed rather than ctrl+a.

I believe that I need to ensure the current tab is the active tab first then run the send keys method. My forum search here found a similar post, where someone used the following code in NT7:

// Make sure chart window is active.
ChartControl.ParentForm.Activate();

However this method is not avaialble in NT8, can anyone help with an equivalent NT8 code to use to ensure the chart window is active before running the send keys method?

If anyone knows of some other cause of the unexpected action resulting in the search getting activated on sending the hotkey, please let me know.

Many thanks

Reply With Quote
 
  #2 (permalink)
Dubai + United Arab Emirates
 
 
Posts: 8 since Jan 2020
Thanks: 2 given, 3 received

Have you tried the ChartPanel class?
It has an .IsFocused method that might help.


It may be a good idea to loop through a collection of open windows before triggering the sendkey, just to make sure you're dealing with the correct window

I hope this helps.

Reply With Quote
The following user says Thank You to SamirOfSalem for this post:
 
  #3 (permalink)
London
 
Trading Experience: None
Platform: ninjatrader
Favorite Futures: ftse100
 
Posts: 36 since Sep 2017
Thanks: 7 given, 6 received


Thanks for the suggestion Samir. I tried the IsFocused and receive an error: The calling thread cannot access this object because a different thread owns it. Do you know how to overcome this?

Edit: Solved, It needs to go within a dispatcher, this is all new to me but i'm trying to work it out...

Reply With Quote
 
  #4 (permalink)
Dubai + United Arab Emirates
 
 
Posts: 8 since Jan 2020
Thanks: 2 given, 3 received


b16aln View Post
Thanks for the suggestion Samir. I tried the IsFocused and receive an error: The calling thread cannot access this object because a different thread owns it. Do you know how to overcome this?

Edit: Solved, It needs to go within a dispatcher, this is all new to me but i'm trying to work it out...

Good to hear. There are some interesting threads on the NinjaTrader forum for this kind of thing, but sendkeys per se is not supported. One example is in the link below by Ninja's very helpful Chelsea. If the link doesn't show, just do a search on the forum for "Modifications to chart WPF elements and tab considerations".

https://ninjatrader.com/support/forum/forum/ninjatrader-8/indicator-development/96376-modifications-to-chart-wpf-elements-and-tab-considerations

I'm not sure if it was in this particular thread, but I remember once reading a discussion where it was realized that a custom toolbar was appearing on only one tab of an open chart window. It was a dispatcher issue if I recall. The NT team then revised the code so that it checks which tabs/windows are open and/or have focus.

Reply With Quote
The following user says Thank You to SamirOfSalem for this post:
 
  #5 (permalink)
London
 
Trading Experience: None
Platform: ninjatrader
Favorite Futures: ftse100
 
Posts: 36 since Sep 2017
Thanks: 7 given, 6 received

Thanks, I'll look into it all. This stuff is really pushing my coding abilities (beginner) but I'll keep plugging away at it to try and get to where I want it to be. Getting some pretty funky outcomes at the moment and one major system crash this morning but I'll keep trying...and backing up as I go!

Reply With Quote
 
  #6 (permalink)
Administrator: Retired Backtester
Rennes France
 
Trading Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,596 since Jun 2009
Thanks: 3,750 given, 4,385 received


b16aln View Post
Thanks, I'll look into it all. This stuff is really pushing my coding abilities (beginner) but I'll keep plugging away at it to try and get to where I want it to be. Getting some pretty funky outcomes at the moment and one major system crash this morning but I'll keep trying...and backing up as I go!

You may check what NinjaTrader.Gui.Tools.TabControlCommands.DuplicateInTab.execute(param) is doing. It's not documented so may be tricky to use.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:
 
  #7 (permalink)
London
 
Trading Experience: None
Platform: ninjatrader
Favorite Futures: ftse100
 
Posts: 36 since Sep 2017
Thanks: 7 given, 6 received

Thanks Sam, I couldn't get that option to work.

I'm getting there, the Focus method appears to be working and I am then checking it by printing the IsFocused bool output, e.g when IsFocused is true I am treating that as confimation that the correct chart is in selected.

When I then fire off the send keys I get the following error;

"Error on calling 'OnBarUpdate' method on bar 10983: Source array was not long enough. Check srcIndex and length, and the array's lower bounds."

So i'm stuck again.....

The code currently looks like;

if(useAutoTabDuplicate==true)
{
useAutoTabDuplicate=false;

ChartControl.Dispatcher.InvokeAsync((Action)(() =>
{
ChartControl.OwnerChart.Focus();
Print(ChartPanel.IsFocused);
}));

System.Windows.Forms.SendKeys.SendWait("^z");
}

The autoTabDuplicate is just a bool switch so that I don't get an infinite loop of charts being duplicated.

Can anyone help me get passed the error?


EDIT: Ok realised I was mixing ChartControl with ChartPanel. When I use ChartControl.IsFocused it returns false so the ChartControl.OwnerChart.Focus() doesn;t appear to be working.


Last edited by b16aln; January 2nd, 2020 at 07:07 AM.
Reply With Quote
 
  #8 (permalink)
London
 
Trading Experience: None
Platform: ninjatrader
Favorite Futures: ftse100
 
Posts: 36 since Sep 2017
Thanks: 7 given, 6 received

Found it

In case anyone interested, this worked;
ChartControl.OwnerChart.OnDuplicateInNewTab();
Thanks for all your help guys, very helpful indeed!

Reply With Quote

Reply



futures io > > > > NT8 send keys

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Using Order Flow Analysis & Longer Term Trading w/John @ No BS Trading

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Hot keys NT8. (Modal form has focus) Chronos24 NinjaTrader 1 April 20th, 2018 11:09 PM
anyone have example send key for NT8 to do F5? tulanch NinjaTrader Programming 3 April 13th, 2017 04:01 PM
Do you use Hot Keys in NinjaTrader 7? Big Mike NinjaTrader 2 December 10th, 2010 01:15 PM
Hot keys programming different windows MetalTrade NinjaTrader 5 December 9th, 2010 12:13 PM
Output Screen Copy Paste Control Keys!!! RJay Traders Hideout 3 November 2nd, 2009 01:06 PM


All times are GMT -4. The time now is 06:18 PM. (this page content is cached, log in for real-time version)

Copyright © 2020 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