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

How to get code to fire whenever a manually entered order is filled

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

    How to get code to fire whenever a manually entered order is filled

    Hi,

    I would like a block of code in my Strategy to fire anytime an order is filled, whether that order was placed algorithmically or manually. I'm assuming it has something to do with OnExecution(), but my following block of code produces nothing:

    Code:
    protected override void OnExecution(IExecution execution)
    {
    	if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
    	{
    		Print("Time: " + Time[0]);
    	}
    				
    }
    What am I missing? Any assistance is much appreciated.

    Thanks.

    -Nick

    #2
    Hello Nicbizz,

    Thank you for your post.

    You won't be able to get other strategy's or manual orders executions to show up in one strategy. The OnExecution only works per the instance of the strategy running and will only get called for orders placed by that strategy.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      Thanks for the prompt reply.

      Is there anyway I can manage an order placed manually using the Strategy code?

      For example, I would like to automatically enter an exit order (based on certain criteria) when a manually entered long order is filled.

      Or how about code to check if I'm long any positions at all? (Position.MarketPosition only applies for entries managed by a Strategy)

      Thanks.

      -Nick
      Last edited by nicbizz; 09-26-2014, 02:09 PM.

      Comment


        #4
        Nick,

        There is an unsupported method for grabbing the account information.

        Essentially you would query the Account information allowing you to create OrderUpdate or ExecutionUpdate handlers.

        See the link below for more information
        http://www.ninjatrader.com/support/f...ad.php?t=55718
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Cal,

          Thanks!

          Long shot here, but is there also an unsupported method to access manual executions through the Strategy system?

          -Nick

          Comment


            #6
            Nick,

            Yes, there is. When you have queried the account you then need to create an event handler for ExectionUdpateEvent -
            Code:
            account.Execution += new ExecutionUpdateEventHandler(MyExecution);
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Looks like I'll need to experiment a bit with the code.

              Thanks for the pointers, Cal.

              -Nick

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by dward123, 01-02-2024, 09:59 PM
              3 responses
              161 views
              0 likes
              Last Post bjunaid
              by bjunaid
               
              Started by ETFVoyageur, Today, 04:00 PM
              1 response
              7 views
              0 likes
              Last Post ETFVoyageur  
              Started by AaronKTradingForum, Today, 03:44 PM
              1 response
              8 views
              0 likes
              Last Post AaronKTradingForum  
              Started by Felix Reichert, 04-26-2024, 02:12 PM
              11 responses
              77 views
              0 likes
              Last Post Felix Reichert  
              Started by junkone, 04-28-2024, 02:19 PM
              7 responses
              83 views
              1 like
              Last Post junkone
              by junkone
               
              Working...
              X