Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How Do I perform the Event button without actual clicking on the button?

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

    How Do I perform the Event button without actual clicking on the button?

    Hi,

    I have a button ClosePositionButton with event CloseButtonClick. I want to close my position before the market closes without clicking the ClosePositionButton button, how do I do that in a program?

    closePositionButton.Click += ClosePositionClick;

    protected void ClosePositionClick(object sender, RoutedEventArgs e)
    {
    //Perform function​
    }

    Thanks.

    #2
    Originally posted by kezyclaire View Post
    I have a button ClosePositionButton with event CloseButtonClick. I want to close my position before the market closes without clicking the ClosePositionButton button, how do I do that in a program?
    I don't know much about programmatically 'clicking' the
    Close button.

    But, they are are other ways to close out your position(s)
    before the market closes.

    Why are you wanting to simulate the button click?

    Have you looked at NT's auto close feature?

    Comment


      #3
      It is not just closing position, I just stated above ClosePositionClick for an example. I just want to know how to call below event in just one statement without using a mouse. In other programming languages, there is this ClosePositionClick.PerformClick(), what about in ninjascript?

      protected void ClosePositionClick(object sender, RoutedEventArgs e)
      {
      }

      Thanks.

      Comment


        #4
        Originally posted by kezyclaire View Post
        It is not just closing position, I just stated above ClosePositionClick for an example. I just want to know how to call below event in just one statement without using a mouse. In other programming languages, there is this ClosePositionClick.PerformClick(),what about in ninjascript?
        This is not a NinjaScript question, it's a C# and WPF question.

        Which means you're in luck, Google will have the answers.

        Try this search.

        Last edited by bltdavid; 05-08-2023, 03:36 AM.

        Comment


          #5
          Generally, you can just write ClosePositionClick(null, null); unless your event handler uses those arguments (which often it does not).
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            Hi QuantKey_Bruce,

            That works, thanks. I have tried that before, I have this kind of line commented out but I can't remember if it works previously or not or I did not really try to test it.

            Thanks.

            Comment


              #7
              You're welcome.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              46 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              126 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              66 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              42 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X