Find historical trade using Contains() on Label
30 Oct 2023, 07:59
Hi,
I want to find some historical trades that meet criteria such as a certain string contained in the label. Is this correct?
protected override void OnTick(){ var Str = "ABCDEF"; ExecuteMarketOrder(TradeType.Sell, SymbolName, Symbol.VolumeInUnitsMin, Str); ClosePosition(Positions.Find(Str)); var X = History.Where(T => T.Label.Contains("ABC")).Count(); Print(X);}
This code return error during Count() function…
30/10/2023 15:49:17.632 | Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object.
Please help me do it correctly.
Thanks.

PanagiotisChar
31 Oct 2023, 07:32
Hi Abdul,
Try
History.Where(T => T.Label != null && T.Label.Contains("ABC")).Count()@PanagiotisChar