Expected Behavior
After Reset(), an indicator produces the same values on a replay as a fresh instance fed the same bars.
Actual Behavior
AdvanceDeclineIndicator.Reset() clears _advanceDeclineDictionary and _previousPeriodValues but leaves _currentPeriodTime (line 34) holding the last period it processed. Enqueue (lines 165 and 176) only files a bar whose Time reaches that watermark, so after a reset every bar earlier than the old watermark is dropped without a warning and the indicator stays unready for the rest of the replay.
Measured over 60 daily periods across 3 symbols, comparing a reset-and-replayed instance against a fresh one: 162 of 180 updates differ in value and 171 of 180 differ in IsReady. Minute resolution behaves the same.
This also affects AdvanceDeclineDifference, AdvanceDeclineRatio, AdvanceDeclineVolumeRatio, McClellanOscillator and McClellanSummationIndex, which all build on it.
Potential Solution
Clear _currentPeriodTime in Reset() alongside the two dictionaries.
Reproducing the Problem
ComparesAgainstExternalDataAfterReset does not catch this. TestHelper.AssertIndicatorHasExternalDataAfterReset skips its assertion while the indicator is not ready, and on master the second pass of that test asserts 0 of 756 rows for all three A/D indicators — the reset leaves the indicator permanently unready, so every row is skipped and the test passes vacuously. With _currentPeriodTime cleared it asserts 753 of 756.
A direct test: feed the indicator a set of bars, call Reset(), feed the same bars again, and compare each Current.Value against a fresh instance fed the same bars once.
System Information
macOS, .NET 9, master at f0e339c.
Checklist
Expected Behavior
After
Reset(), an indicator produces the same values on a replay as a fresh instance fed the same bars.Actual Behavior
AdvanceDeclineIndicator.Reset()clears_advanceDeclineDictionaryand_previousPeriodValuesbut leaves_currentPeriodTime(line 34) holding the last period it processed.Enqueue(lines 165 and 176) only files a bar whoseTimereaches that watermark, so after a reset every bar earlier than the old watermark is dropped without a warning and the indicator stays unready for the rest of the replay.Measured over 60 daily periods across 3 symbols, comparing a reset-and-replayed instance against a fresh one: 162 of 180 updates differ in value and 171 of 180 differ in
IsReady. Minute resolution behaves the same.This also affects
AdvanceDeclineDifference,AdvanceDeclineRatio,AdvanceDeclineVolumeRatio,McClellanOscillatorandMcClellanSummationIndex, which all build on it.Potential Solution
Clear
_currentPeriodTimeinReset()alongside the two dictionaries.Reproducing the Problem
ComparesAgainstExternalDataAfterResetdoes not catch this.TestHelper.AssertIndicatorHasExternalDataAfterResetskips its assertion while the indicator is not ready, and onmasterthe second pass of that test asserts 0 of 756 rows for all three A/D indicators — the reset leaves the indicator permanently unready, so every row is skipped and the test passes vacuously. With_currentPeriodTimecleared it asserts 753 of 756.A direct test: feed the indicator a set of bars, call
Reset(), feed the same bars again, and compare eachCurrent.Valueagainst a fresh instance fed the same bars once.System Information
macOS, .NET 9,
masterat f0e339c.Checklist
masterbranch