Help: Inhibit Ninja Default Mouse action while capturing clicks - NinjaTrader Programming | futures io social day trading
futures io futures trading


Help: Inhibit Ninja Default Mouse action while capturing clicks
Updated: Views / Replies:377 / 2
Created: by SharkPub 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 90,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
 

Help: Inhibit Ninja Default Mouse action while capturing clicks

  #1 (permalink)
Elite Member
Zelienople, PA, USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Futures
 
Posts: 1 since May 2015
Thanks: 1 given, 0 received

Help: Inhibit Ninja Default Mouse action while capturing clicks

I have been able to capture mouse movement and mouse clicks in Ninja Script. Portions of code (apprx 3,000 lines) are shown below. I can intercept the mouse clicks and read the keyboard state to decide how to process the click. The problem is that after intercepting the mouse click, I get the Ninja Trader "mouse action".

The question is: When I decide I want to capture a mouse click, how do I inhibit that mouse click from causing the default ninja trader actions? Alternatively, is there a way to disable the default mouse actions for some period of time, then re-enable them later (i.e. User clicks on a button. Disable all Ninja default mouse actions. Pick points on the chart and record them. Re-enable Ninja default mouse actions).

I am a beginner at this sort of thing, and would appreciate your help.

Thank you! Have a GREAT day!

SharkPub


Code for start up:

// --- mcdOnStartUp() --- Add to end of "OnStartUp()"
private void mcdOnStartUp()
{
if ( bDebug ) Print("mcdOnStartUp()");
bUpdated = false;
if ( (bInstalled = bIsBSModeActive()) == false ) {
// Print("mcdOnStartUp() - not active...");
return;
}

//add the mouse events
// Print("mcdOnStartUp()");
this.ChartControl.ChartPanel.MouseMove += new MouseEventHandler(mcdMouseEvent);
this.ChartControl.ChartPanel.MouseClick += new MouseEventHandler(mcdMouseEvent);

return;
}

Code for event handling:

private void mcdMouseEvent(object sender, MouseEventArgs e)
{
try
{
TriggerCustomEvent(new CustomEvent(mcdMouseTriggerEvent),e );
}
catch (Exception ex)
{
Print("Error1 " + ex.ToString());
}
}

private void mcdMouseTriggerEvent(object state)
{
int loc = 0;
int idx = -3;
int barclick = 0;
bool bDbg = false;

if ( !bUpdated )
return;

if ( curPt == null ) {
curPt = new chartPoint(this);
}
try
{
MouseEventArgs m = (MouseEventArgs)state;
loc = 1;
int bShift = 0, bAlt = 0, bCntrl = 0, bLeft = 0, bRight = 0;
bool bProcessed = false;
// Save points in case they changed
double tptShift0 = ptShift0;
double tptShift1 = ptShift1;
double tptAlt0 = ptAlt0;
double tptAlt1 = ptAlt1;
double tptCntrl0 = ptCntrl0;
double tptCntrl1 = ptCntrl1;
if ( m != null ) {
MouseButtons MBLeft = MouseButtons.Left;
MouseButtons MBRight = MouseButtons.Right;
bShift = (Control.ModifierKeys & Keys.Shift) != 0? 1:0;
bAlt = (Control.ModifierKeys & Keys.Alt) != 0? 2:0;
bCntrl = (Control.ModifierKeys & (Keys.ControlKey | Keys.Control)) != 0? 4:0;
if ( (bShift | bAlt | bCntrl) != 0 && (m.Button & (MBLeft | MBRight)) == (MBLeft | MBRight) ) {
// Both right and left button pressed, clear the oints
if ( bShift != 0 ) { ptShift0 = ptShift1 = 0; if ( bDbg ) Print(" pt Shift reset"); }
if ( bAlt != 0 ) { ptAlt0 = ptAlt1 = 0; if ( bDbg ) Print(" pt Alt reset"); }
if ( bCntrl != 0 ) { ptCntrl0 = ptCntrl1 = 0; if ( bDbg ) Print(" pt Cntrl reset"); }
} else if ( (bShift | bAlt | bCntrl) != 0 &&
(m.Button & (MBLeft | MBRight)) != 0 ) {
// set a point
curPt.setChartPosition(m.X,m.Y,1);
// Set the Y-position
double y = curPt.rYposTick;
if ( (m.Button & MBLeft) != 0 ) {
if ( bShift != 0 ) { ptShift0 = y; if ( bDbg ) Print(" pt Shift 0 set to: "+y.ToString("0.0000")); }
if ( bAlt != 0 ) { ptAlt0 = y; if ( bDbg ) Print(" pt Alt 0 set to: "+y.ToString("0.0000")); }
if ( bCntrl != 0 ) { ptCntrl0 = y; if ( bDbg ) Print(" pt Cntrl 0 set to: "+y.ToString("0.0000")); }
}
if ( (m.Button & MBRight) != 0 ) {
if ( bShift != 0 ) { ptShift1 = y; if ( bDbg ) Print(" pt Shift 1 set to: "+y.ToString("0.0000")); }
if ( bAlt != 0 ) { ptAlt1 = y; if ( bDbg ) Print(" pt Alt 1 set to: "+y.ToString("0.0000")); }
if ( bCntrl != 0 ) { ptCntrl1 = y; if ( bDbg ) Print(" pt Cntrl 1 set to: "+y.ToString("0.0000")); }
}
// Print("Shift="+(bShift==0?"up":"down")+" Alt="+(bAlt==0?"up":"down")+" Cntrl="+(bCntrl==0?"up":"down"));
// Print("Set point to "+y.ToString("0.0000"));
bProcessed = true;
// this.printChartControl(this);
}
// Check for one of the points changed position
if ( tptShift0 != ptShift0 || tptShift1 != ptShift1 ||
tptAlt0 != ptAlt0 || tptAlt1 != ptAlt1 ||
tptCntrl0 != ptCntrl0 || tptCntrl1 != ptCntrl1 ) {
// Force re-serialization of the data
barEntrySerialData.serializeClass( getInstrument(this), this );
}
....
}
}
catch (Exception ex)
{
Print("Error loc="+loc.ToString()+" computing projection bar: "+ex.ToString());
}
return;
}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


@SharkPub

 
Code
    HandledMouseEventArgs ee = (HandledMouseEventArgs) e;

    ee.Handled = true;

Sometimes Windows/NT gets a strop on about this sort of thing but it's often good on Tuesdays, except when it decides to bar it or ignore it completely, so don't expect it to work 100%, I have used it but don't rely on it.

Be aware to treat moves, down clicks, up clicks, wheel moves separately as required (I prefer separate handler routines), also for the keyboard not all keys give you up and down, e.g. arrow keys you just get the up and no auto repeat, whereas the control/alt/shift keys you get up and down with auto-repeat..

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:

Reply



futures io > > > > > Help: Inhibit Ninja Default Mouse action while capturing clicks

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing keystrokes: Alt, Up Arrow, Down Arrow vantojo NinjaTrader Programming 4 September 15th, 2014 12:32 PM
Ninja Price Action Indicator PeterBrazel NinjaTrader 2 July 23rd, 2014 07:30 PM
Ninja Stop Order without Middle Mouse? daedalus NinjaTrader 3 June 7th, 2013 06:07 AM
Ninja Price Action Indicator Refreshing jsewell714 NinjaTrader Programming 1 July 12th, 2012 04:33 PM
Set "Default 24/7" as default setting on strategy zwentz NinjaTrader Programming 6 January 18th, 2011 12:37 PM


All times are GMT -4. The time now is 09:43 PM.

Copyright © 2017 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
Page generated 2017-12-12 in 0.10 seconds with 19 queries on phoenix via your IP 54.221.93.187