Skip to content

Clear the advance decline period watermark on reset - #9686

Merged
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
mkzung:bug-9683-advance-decline-reset-period-watermark
Aug 12, 2026
Merged

Clear the advance decline period watermark on reset#9686
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
mkzung:bug-9683-advance-decline-reset-period-watermark

Conversation

@mkzung

@mkzung mkzung commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

AdvanceDeclineIndicator.Reset() clears both period dictionaries but leaves _currentPeriodTime holding the last period it processed. Enqueue only files a bar whose Time reaches that watermark, so after a reset every earlier bar is dropped and the indicator never becomes ready again. Clearing the watermark alongside the dictionaries is the whole fix.

The test doubles in McClellanOscillatorTests and McClellanSummationIndexTests seed the EMA values implied by the A/D history preceding their CSV. That seeding ran once, in the constructor, so it did not survive a reset. It moves into their Reset override, which the constructor already calls. Without this the two fixtures fail once the indicator starts producing values after a reset, which is the point of the change.

Related Issue

Fixes #9683.

Motivation and Context

Reset is meant to return an indicator to its constructed state. Here it left one field set, and the field gates whether any further data is accepted at all, so the indicator went quiet rather than wrong. 162 of 180 updates differ from a fresh instance over 60 daily periods across 3 symbols, and 171 of 180 differ in IsReady.

AdvanceDeclineDifference, AdvanceDeclineRatio, AdvanceDeclineVolumeRatio, McClellanOscillator and McClellanSummationIndex all build on this indicator.

Requires Documentation Change

No.

How Has This Been Tested?

ResetsProperlyAndReplaysTheSameValues in AdvanceDeclineDifferenceTests feeds the indicator, resets it, replays the same bars, and compares each value and IsReady against a fresh instance. It fails on master and passes with the fix. Being in the shared A/D fixture, it is inherited by the ratio and volume-ratio fixtures too.

QuantConnect.Tests.Indicators on a clean checkout of this branch: 2768 passed, 0 failed, 5 skipped, on .NET 9 under Linux.

Worth flagging separately: TestHelper.AssertIndicatorHasExternalDataAfterReset skips its assertion while the indicator is not ready, so on master the second pass of ComparesAgainstExternalDataAfterReset asserts 0 of 756 rows for all three A/D indicators and passes vacuously. With this fix it asserts 753 of 756. That helper is inherited by roughly 200 fixtures, so tightening it is a separate discussion rather than part of this PR.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description>

AdvanceDeclineIndicator.Reset left _currentPeriodTime holding the last
period it had seen. Enqueue only files a bar whose Time reaches that
watermark, so after a reset every earlier bar was dropped silently and
the indicator stayed unready for the whole replay. Clear the watermark
along with the two period dictionaries.

The McClellan test doubles seed the EMA values implied by the A/D history
that precedes their CSV. That seeding ran once in the constructor, so the
second half of ComparesAgainstExternalDataAfterReset compared unseeded
EMAs against the file. Move it into their Reset override, which the
constructor already calls.

@Martin-Molinero Martin-Molinero left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mkzung!

@Martin-Molinero
Martin-Molinero merged commit 2859d31 into QuantConnect:master Aug 12, 2026
7 of 8 checks passed
@mkzung mkzung mentioned this pull request Aug 13, 2026
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AdvanceDeclineIndicator.Reset leaves the period watermark set, so it silently drops every later bar

2 participants