I think that "Now" that @NinjaTrader_ZacharyG mentioned should be programmed to do what you programmed automatically. Can it be added as a request? a Now property that adjusts to connections. If in backtest mode, it can be adjusted to the last Time[0] of the time series calculated.
I still don't understand what you are doing with the milliseconds... If you are trying to remove them why not just now = now.AddMilliseconds(-1 * now.Millisecond)?
Comment