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

Mouse down

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

    Mouse down

    Hi,

    Not sure why this doesn't work
    Can anyone help?

    protected override void OnStartUp()
    {
    this.ChartControl.MouseDown+=mouseDownHandler;

    }
    private void mouseDownHandler(object sender, MouseEventArgs e)
    {
    Print(
    "Hello");
    string eventString = null;
    switch (e.Button)
    {
    case MouseButtons.Left:
    eventString =
    "L";
    break;
    case MouseButtons.Right:
    eventString =
    "R";
    break;
    case MouseButtons.Middle:
    eventString =
    "M";
    break;
    case MouseButtons.None:
    default:
    break;
    }

    if (eventString=="L")
    {
    Print(
    "Left Mouse");
    }
    else
    {
    Print(
    "Null");
    }
    }

    Thanks
    Bruce

    #2
    Burce, as this would be a more general C# question and therefore unfortunately not supported by us here - I'm leaving this thread open though if a fellow coder from the forums has an idea for you.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      check out this thread:

      I have basic C# skills, just enough to be dangerous. But I'll point you in the right direction. This code should remove all the user drawn horizontal lines if the instrument changes. I haven't tried to run it or compile it and it might be all horribly wrong so good luck. //Variables string chartInstrument; // On Bar Update protected override void OnBarUpdate() { if (chartInstrument == null) { chartInstrument = Instrument.FullName; } else { if ( chartInstrument …


      let us know what you figure out. thanks


      Originally posted by tacticaltrader View Post
      Hi,

      Not sure why this doesn't work
      Can anyone help?

      protected override void OnStartUp()
      {
      this.ChartControl.MouseDown+=mouseDownHandler;

      }
      private void mouseDownHandler(object sender, MouseEventArgs e)
      {
      Print(
      "Hello");
      string eventString = null;
      switch (e.Button)
      {
      case MouseButtons.Left:
      eventString =
      "L";
      break;
      case MouseButtons.Right:
      eventString =
      "R";
      break;
      case MouseButtons.Middle:
      eventString =
      "M";
      break;
      case MouseButtons.None:
      default:
      break;
      }

      if (eventString=="L")
      {
      Print(
      "Left Mouse");
      }
      else
      {
      Print(
      "Null");
      }
      }

      Thanks
      Bruce

      Comment


        #4
        solution

        Hi there,

        i'd been struggling a little with this also. Here's the way you make it work. There's a problem with the way you've added the declaration for the event:

        protected override void OnStartUp()
        {
        ChartControl.ChartPanel.MouseClick += new System.Windows.Forms.MouseEventHandler(mouseClickH andler);
        }

        public void mouseClickHandler(object sender, System.Windows.Forms.MouseEventArgs e)
        {
        // ...
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by habeebft, Today, 07:27 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by AveryFlynn, Today, 04:57 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Max238, Today, 01:28 AM
        4 responses
        37 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by r68cervera, Today, 05:29 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X