The following if statement placed in OnBarUpdate does the job for the won or lost trades but doesn't work when the ToTime statement is added. If I start the strategy at 9:30 and I have the ToTime clause, the consequence of the if statement executes immediately; without the ToTime, it waits for the 2 wins or losses.
closingTime is set to 154800
if(Performance.RealtimeTrades.WinningTrades.Count >= 2 ||Performance.RealtimeTrades.LosingTrades.Count >= 2 || ToTime(Time[0]) >= closingTime)

Comment