Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

OnMouseMove doesn't exist??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    OnMouseMove doesn't exist??

    All I am trying to do right now is get the mouse coords to track on a chart. I have implemented the example code in the ninja support page.. https://ninjatrader.com/support/helpGuides/nt8/en-us/?onmousemove.htm

    Every time I try to compile the code, I get the error:
    NinjaTrader.NinjaScript.Indicators.AAmousestuff.On MouseMove(NinjaTrader.Gui.Chart.ChartControl, NinjaTrader.Gui.Chart.ChartPanel, NinjaTrader.Gui.Chart.ChartScale, NinjaTrader.NinjaScript.DrawingTools.ChartAnchor): no suitable method found to override
    It displays as error code CS0115

    I checked the micosoftC# codebase
    https://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmousemove(v=vs.110) .aspx and made sure to add
    Code:
    using System.Windows.Forms;
    which I did not originally have in the code. Still, no change.

    If anyone has the time to check this, here is the code:

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    using System.Windows.Forms;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class AAmousestuff : Indicator
        {
            private ChartAnchor lastMouseMoveAnchor = new ChartAnchor();
            private ChartAnchor MyAnchor;
            
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                            = @"Enter the description for your new custom Indicator here.";
                    Name                                = "AAmousestuff";
                    Calculate                            = Calculate.OnEachTick;
                    IsOverlay                            = false;
                    DisplayInDataBox                    = true;
                    DrawOnPricePanel                    = true;
                    DrawHorizontalGridLines                = true;
                    DrawVerticalGridLines                = true;
                    PaintPriceMarkers                    = true;
                    ScaleJustification                    = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event. 
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive            = true;
                }
                else if (State == State.Configure)
                {
                }
                /*else if (State == State.DataLoaded)
                {
                    if (this.ChartPanel != null) { this.ChartPanel.MouseMove += new MouseEventHandler(OnMouseMove); }
                }*/
            }
    
            protected override void OnBarUpdate()
            {
                //Add your custom indicator logic here.
            }
            
            public override void OnMouseMove(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
            {
                // add any logic for when the mouse is moved here
                if (DrawingState == DrawingState.Moving)
                {
                    //move the chart anchor when the drawing tool is in a moving state
                    
                    MyAnchor.MoveAnchor(lastMouseMoveAnchor, dataPoint, chartControl, chartPanel, chartScale, this);
                    
                    // dont forget to update delta point to last used!
                    dataPoint.CopyDataValues(lastMouseMoveAnchor);
                }
            }
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private AAmousestuff[] cacheAAmousestuff;
            public AAmousestuff AAmousestuff()
            {
                return AAmousestuff(Input);
            }
    
            public AAmousestuff AAmousestuff(ISeries<double> input)
            {
                if (cacheAAmousestuff != null)
                    for (int idx = 0; idx < cacheAAmousestuff.Length; idx++)
                        if (cacheAAmousestuff[idx] != null &&  cacheAAmousestuff[idx].EqualsInput(input))
                            return cacheAAmousestuff[idx];
                return CacheIndicator<AAmousestuff>(new AAmousestuff(), input, ref cacheAAmousestuff);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.AAmousestuff AAmousestuff()
            {
                return indicator.AAmousestuff(Input);
            }
    
            public Indicators.AAmousestuff AAmousestuff(ISeries<double> input )
            {
                return indicator.AAmousestuff(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.AAmousestuff AAmousestuff()
            {
                return indicator.AAmousestuff(Input);
            }
    
            public Indicators.AAmousestuff AAmousestuff(ISeries<double> input )
            {
                return indicator.AAmousestuff(input);
            }
        }
    }
    
    #endregion


    This is the code in its entirety, so you should be able to copy it over a pre-gen indicator

    #2
    Hello,

    Thank you for the post.

    The help guide section you have linked is for Drawing Tools specifically, you will need to take note while using the HelpGuide as to what Type the information belongs to. DrawingTools specifically have this override where an Indicator does not.

    You could see the following post for some example on how to access the Mouse events from a indicator: http://ninjatrader.com/support/forum...ad.php?t=86460

    Additionally the MSDN article you had linked is for Winforms(system.windows.forms), NinjaTrader 8 does not use Winforms at all but instead uses WPF. For information you may find using a search, please make sure to search for "WPF" specific information for NT8. If the information is for Winforms, there is a very good chance it will not work.

    Here is the WPF equivalent:



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kevinenergy, 02-17-2023, 12:42 PM
    117 responses
    2,764 views
    1 like
    Last Post jculp
    by jculp
     
    Started by Mongo, Today, 11:05 AM
    5 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by SightCareAubetter, Today, 12:55 PM
    0 responses
    3 views
    0 likes
    Last Post SightCareAubetter  
    Started by traderqz, Today, 12:06 AM
    8 responses
    16 views
    0 likes
    Last Post traderqz  
    Started by SightCareAubetter, Today, 12:50 PM
    0 responses
    2 views
    0 likes
    Last Post SightCareAubetter  
    Working...
    X