Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecutionUpdate

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

    OnExecutionUpdate

    could someone check that I have this right ..

    Code:
    		protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    		{
    			if (execution.Order.Name.StartsWith("EnterLong"))
    			{
    				if (orderState == OrderState.Filled || orderState == OrderState.PartFilled)
    		  		{
    					//long position open
    			 	}
    			}
    			else if (execution.Order.Name.StartsWith("ExitLong"))
    			{
    				if (orderState == OrderState.Filled || orderState == OrderState.PartFilled)
    				{
    					//long position closed				
    				}
    			}
    			else if (execution.Order.Name.StartsWith("ExitLongLimit"))
    			{
    				if (orderState == OrderState.Accepted)
    		  		{
    					//ExitLongLimit accepted
    				}
    				else if (orderState == OrderState.Cancelled)
    		  		{
    					//ExtLongLimit cancelled e.g. CancelOrder()
    				}
    				else if (orderState == OrderState.Filled || orderState == OrderState.PartFilled)
    		  		{
    					//ExitLongLimit filled, long position closed
    				}
    			}
    		}
    I used the following order names e.g. EnterLong, ExitLong & ExitLongLimit
    Last edited by delTik; 04-27-2016, 10:13 AM.

    #2
    Hello delTik,

    I would not be able to say if this is correct as the code that places the entry orders is not included. The names you are looking for would need to match the signal names used for the order.

    Using string.StartsWith is fine to use.

    You can also use IOrders to match orders.

    For the most part this looks fine.
    The question is, when you test the code does it do what you are expecting?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jonafare, 12-06-2012, 03:48 PM
    5 responses
    3,984 views
    0 likes
    Last Post rene69851  
    Started by Fitspressorest, Today, 01:38 PM
    0 responses
    2 views
    0 likes
    Last Post Fitspressorest  
    Started by Jonker, Today, 01:19 PM
    0 responses
    2 views
    0 likes
    Last Post Jonker
    by Jonker
     
    Started by futtrader, Today, 01:16 PM
    0 responses
    7 views
    0 likes
    Last Post futtrader  
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,792 views
    0 likes
    Last Post aligator  
    Working...
    X