I have a pairs trading strategy that goes long one instrument and simultaneously shorts a different instrument. I tried to find a best practice for where best to place the second entry on the forum, but couldn't.
I ideally want to make sure that the first order is filled before placing the second order (they will be market orders), so I tried putting the second EnterLong() in onExecutionUpdate(), when the relevant fromEntrySignal from the first entry is seen:
if (execution.Order != null && execution.Order.OrderState == OrderState.Filled) { // Initial Entry if(execution.Order.FromEntrySignal == "LongSpread") { Print("EnterShort at: "+execution.Time.ToLocalTime()); EnterShort(0,DefaultQuantity,entryName+"Short"); }
Any help appreciated!
Comment