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 TradeSaber, Today, 10:11 PM
              0 responses
              2 views
              0 likes
              Last Post TradeSaber  
              Started by GreyKerns09, Today, 03:42 PM
              1 response
              12 views
              0 likes
              Last Post marco231  
              Started by marco231, 05-15-2024, 11:32 PM
              3 responses
              20 views
              0 likes
              Last Post marco231  
              Started by mrgreentrading, Today, 08:29 PM
              0 responses
              11 views
              0 likes
              Last Post mrgreentrading  
              Started by rbendson, Today, 08:18 PM
              0 responses
              2 views
              0 likes
              Last Post rbendson  
              Working...
              X