Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Partial fills help

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

    Partial fills help

    Hi,

    I am having an issue during partial fills where I am missing the confirmation in OnExecutionUpdate.

    Background: I enter a position using 3 separate brackets (Bracket 1, 2, 3). In OnExecutionUpdate, I wait until all are filled and then set profits/target.

    The issue is that sometimes on partial orders, I will get confirmation that 1 or 2 of the brackets were filled, but never on the last bracket - so my target/stops never get set.

    Any advice on what I might be doing wrong?

    Code:
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    		{
    			if (execution.Order != null && execution.Order.Name == "Long Entry 1")
    			{
    				if (execution.Order.OrderState == OrderState.Filled)
    				{
    					order1Filled = true;
    					orderTime = execution.Order.Time;
    					logEntry(Instrument.MasterInstrument.Name+"\t"+"Bracket 1 Filled - Quantity: "+execution.Order.Quantity+"\t"+"Price: "+execution.Order.AverageFillPrice);
    				}
    			}
    			if (execution.Order != null && execution.Order.Name == "Long Entry 2")
    			{
    				if (execution.Order.OrderState == OrderState.Filled)
    				{
    					order2Filled = true;
    					orderTime = execution.Order.Time;				
    					logEntry(Instrument.MasterInstrument.Name+"\t"+"Bracket 2 Filled - Quantity: "+execution.Order.Quantity+"\t"+"Price: "+execution.Order.AverageFillPrice);
    				}
    			}
    			if (execution.Order != null && execution.Order.Name == "Long Entry 3")
    			{
    				if (execution.Order.OrderState == OrderState.Filled)
    				{
    					order3Filled = true;
    					orderTime = execution.Order.Time;
    					logEntry(Instrument.MasterInstrument.Name+"\t"+"Bracket 3 Filled - Quantity: "+execution.Order.Quantity+"\t"+"Price: "+execution.Order.AverageFillPrice);
    				}
    			}
    			
    			
    			if (bracketUnits == 1 && order1Filled)
    				orderFilled = true;
    			if (bracketUnits == 2 && order1Filled && order2Filled)
    				orderFilled = true;
    			if (bracketUnits == 3 && order1Filled && order2Filled && order3Filled)
    				orderFilled = true;
    			
    			if (orderFilled)
    				logEntry(Instrument.MasterInstrument.Name+"\t"+"Order Complete - Quantity: "+Position.Quantity+"\t"+"Price: "+Position.AveragePrice);
    
    			
    			// set stop and profit targets
    			if (orderFilled && !setTargetsFlag)
    				setTargets();
    			}
    Thanks,
    Alex

Latest Posts

Collapse

Topics Statistics Last Post
Started by charlesugo_1, 05-26-2026, 05:03 PM
0 responses
67 views
0 likes
Last Post charlesugo_1  
Started by DannyP96, 05-18-2026, 02:38 PM
1 response
149 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by CarlTrading, 05-11-2026, 05:56 AM
0 responses
162 views
0 likes
Last Post CarlTrading  
Started by CarlTrading, 05-10-2026, 08:12 PM
0 responses
99 views
0 likes
Last Post CarlTrading  
Started by Hwop38, 05-04-2026, 07:02 PM
0 responses
286 views
0 likes
Last Post Hwop38
by Hwop38
 
Working...
X