NexusFi: Find Your Edge


Home Menu

 





ChartControl.ChartPanel.MouseMove += new System.Windows.Forms.MouseEventHandler issue


Discussion in NinjaTrader

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




 
Search this Thread

ChartControl.ChartPanel.MouseMove += new System.Windows.Forms.MouseEventHandler issue

  #1 (permalink)
 erk707 
Irvine, CA
 
Experience: Intermediate
Platform: Ninjatrader
Trading: Piano, ES, GC, CL, NQ, 6E
Posts: 21 since Feb 2011
Thanks Given: 5
Thanks Received: 4

I have a strategy that tracks the Y axis of the mouse pointer with ChartControl.ChartPanel.MouseMove += new System.Windows.Forms.MouseEventHandler

Everything works fine if I open a brand new chart. Anytime I reload ninjascript it appears my MouseMove is no longer tracked and it stops printing to the screen. The only way i can fix it is if I close the chart and open a brand new one.

I am handling it in OnTermination().

Any ideas?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Exit Strategy
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Build trailing stop for micro index(s)
Psychology and Money Management
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 erk707 
Irvine, CA
 
Experience: Intermediate
Platform: Ninjatrader
Trading: Piano, ES, GC, CL, NQ, 6E
Posts: 21 since Feb 2011
Thanks Given: 5
Thanks Received: 4


Below is the sample code if anyone can help

 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;

using System.Windows.Forms;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class MouseMoveTest : Strategy
    {
        #region Variables
        // Wizard generated variables
        private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            CalculateOnBarClose = false;
        }

		protected override void OnStartUp()
		{
			ChartControl.ChartPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(OnChartPanelMouseEventMove);
		}
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
			
        }
		
		public int cursor;
		public bool isMouseDown;
		private void OnChartPanelMouseEventMove(Object sender, MouseEventArgs e)
		{
			cursor = e.Y;
			DrawTextFixed("jk2jf83f344", "Mouse Y Coord: " + cursor.ToString(), TextPosition.TopRight);
			Print("Mouse down " + isMouseDown);
			if(!isMouseDown)
				return;
			Print("Mouse down " + isMouseDown);
			
//			chartTraderForm.adjustTakeProfit("mouseMoveEvent", cursor);
		}
		
		protected override void OnTermination()
		{
			ChartControl.ChartPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(OnChartPanelMouseEventMove);
		}
		
        #region Properties
        [Description("")]
        [GridCategory("Parameters")]
        public int MyInput0
        {
            get { return myInput0; }
            set { myInput0 = Math.Max(1, value); }
        }
        #endregion
    }
}

Started this thread Reply With Quote
  #4 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


erk707 View Post
Below is the sample code if anyone can help

You need '-=' instead of '+=' to remove the handler in OnTermination.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 erk707 
Irvine, CA
 
Experience: Intermediate
Platform: Ninjatrader
Trading: Piano, ES, GC, CL, NQ, 6E
Posts: 21 since Feb 2011
Thanks Given: 5
Thanks Received: 4

Rookie mistake

Dont know how many times i looked at that and didnt catch it.

Started this thread Reply With Quote
Thanked by:




Last Updated on August 16, 2014


© 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