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 wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        26 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, Yesterday, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        192 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,234 views
        0 likes
        Last Post xiinteractive  
        Working...
        X