I'm trying to find the target price of a SL/TP order that I set inside the OnExecutionUpdate event handler, but I have no reference saved to it (declare an Order field for it, for example), I'm trying to make it robust to work on multiple scenarios.
I think the only case this wouldn't work is if I have multiple Entries per Direction
Just wondering if there's a better alternative when not using these automatic Sets() methods.
var findOrderOfAnEntry = Orders. FirstOrDefault(x => x.Name == "SL Buy" && x.FromEntrySignal == "Buy" && //Search for a SL or a TP of a Buy x.OrderUpdates.All(y => y.Filled == 0) && //Not Filled x.OrderUpdates.Any(y => y.OrderState == OrderState.Working) && //Currently Working x.OrderUpdates.All(y => !y.OrderState.ToString().Contains("Cancel"))); //Not Cancelled, CancelPending, CancelSubmitted
Comment