NexusFi: Find Your Edge


Home Menu

 





Help with NinjaScript strategy keyboard event


Discussion in NinjaTrader

Updated
    1. trending_up 978 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Help with NinjaScript strategy keyboard event

  #1 (permalink)
DoctorJR
Fort Myers
 
Posts: 3 since Oct 2019
Thanks Given: 1
Thanks Received: 1

Help with Ninjascript:

I'd like to activate the trade entries portion of my Ninascript stategy with a keyboard event such as CapsLock. The general idea is that the strategy would always be running but a condition of any trade entry would be CapsLock being in the down position.

Using the standard NinjaTrader tools to turn the strategy on and off is too cumbersome for the quick decisions I need to make. My primary purpose here is to make more efficient trade entries. I experience too many misses when I do it manually.

The most on topic information I've located so far is a discussion of the c# Keyboard.IsKeyDown(Key) Method at a MS C# site.

I can't post the url here but you can locate it by Googling "Keyboard.IsKeyDown(Key) Method"

I'm confident this is the stuff I need but I can't get it to compile and run. When I declare the bool referenced at the above MS C# site I get a message telling me I must declare a body, and that has left me rather clueless.

Any suggestions anyone? Thanks in advance.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Cheap historycal L1 data for stocks
Stocks and ETFs
Quant vue
Trading Reviews and Vendors
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,176
Thanks Received: 6,020

It is not necessary to turn the stragey on/off, you just need to track what you need to track to set a variable which would determine if it is OK to open a trade or not.

private void KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
IdKeyPressed = e.Key.ToString().ToLower();
//Print("keyPressed Down = " + IdKeyPressed);
}

private void KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{

if (IdKeyPressed == "tab")
{
// do something if tab key was pressed down
}
IdKeyPressed = string.Empty;

}




DoctorJR View Post
Help with Ninjascript:

I'd like to activate the trade entries portion of my Ninascript stategy with a keyboard event such as CapsLock. The general idea is that the strategy would always be running but a condition of any trade entry would be CapsLock being in the down position.

Using the standard NinjaTrader tools to turn the strategy on and off is too cumbersome for the quick decisions I need to make. My primary purpose here is to make more efficient trade entries. I experience too many misses when I do it manually.

The most on topic information I've located so far is a discussion of the c# Keyboard.IsKeyDown(Key) Method at a MS C# site.

I can't post the url here but you can locate it by Googling "Keyboard.IsKeyDown(Key) Method"

I'm confident this is the stuff I need but I can't get it to compile and run. When I declare the bool referenced at the above MS C# site I get a message telling me I must declare a body, and that has left me rather clueless.

Any suggestions anyone? Thanks in advance.


Reply With Quote
  #3 (permalink)
DoctorJR
Fort Myers
 
Posts: 3 since Oct 2019
Thanks Given: 1
Thanks Received: 1


Thanks for your reply Trend Guy.

I've decided to forget about the keyboard input and use chart buttons to interact with my strategy. This morning I found some code at the NinjaTrader Help Forum (posted by NinaTrader_ZacharyG) , and it looks as though I can tweak it to accomplish my objectives of interacting with my trading strategy without disabling the strategy. I've got 8 current trade setups (4 long and 4 short) and I believe I'll be able to arbitrarily turn each of them on and off. So far the testing looks good. In addition to the basic trading strategy stuff I'm working on a Cancel button, a Close button and a Breakeven button which I hope to be able to activate at my discretion -- also without disabling the strategy. I think I'll test them over the weekend with Market Replay, though Market Replay can be a bit quirky.

I should have thought of this approach long ago but I guess I'm never particularly eager to jump into new programming challenges, though for me clickable chart buttons are far easier to use than the keyboard. I can do the code crunching but I'm far from professional level and my mind is just not particularly methodical. If I programmed for a living I probably get fired a lot, though I managed a B grade working with Fortran and punch cards at Purdue in the late 70s.

My idea with this approach is to make the trades I normally choose, but the without the delays and mistakes inherent in reading charts, digesting indicator data, determining an entry price and fumbling around with the order entry interface. If one is serious about day trading (which I am) I've got to believe this is the way to go. If nothing else, it makes the exercise less stressful. I can do all things I want to do with far greater efficiency. Of course that doesn't guarantee I'll make lots and lots of money, but it improves my chances.

For the record I've invested LOTS of time in developing standalone trading programs but quantifying all the technical analysis I've learned and instinctive market judgement I've developed (Sometimes it's good) over the years is an impossible task in an algorithm-dominated futures market driven by top notch programmers, millions of dollars of development investment and access to proprietary information. So my advice to any beginning day trader would be to learn as much technical analysis as you can (while taking it easy on Elliott Wave Theory) and develop the programming skills to streamline the trading process.

I'm sure this is a much longer response that you wanted and I hope you're still reading. I live in a world where hardly anyone understands anything about what I do (with considerable emotional investment) and I'm jumping at the opportunity to express myself to someone (and perhaps others) familiar with the trading life.


In summary, thumbs up for chart buttons that interact with your trading program.

Reply With Quote
Thanked by:
  #4 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,176
Thanks Received: 6,020


DoctorJR View Post
Thanks for your reply Trend Guy.

I've decided to forget about the keyboard input and use chart buttons to interact with my strategy...

If you need help, just let me know i'll share what i know and learned.

Reply With Quote
Thanked by:




Last Updated on August 7, 2021


© 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