Skip to content

Clear ConnorsRelativeStrengthIndex._previousInput on reset - #9687

Merged
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
mkzung:bug-9684-connors-rsi-reset-previous-input
Aug 12, 2026
Merged

Clear ConnorsRelativeStrengthIndex._previousInput on reset#9687
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
mkzung:bug-9684-connors-rsi-reset-previous-input

Conversation

@mkzung

@mkzung mkzung commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

ConnorsRelativeStrengthIndex.Reset() did not clear _previousInput. Both ComputeNextValue and ComputeTrendStreak read it before writing it, so the first sample after a reset took the percent-rank branch instead of the seeding branch.

Related Issue

Fixes #9684.

Motivation and Context

The stale input put a real price-change ratio into the rolling window where a fresh instance puts zero, and moved the trend streak off zero one sample early. The two instances then disagreed around the point where the lookback window fills.

Requires Documentation Change

No.

How Has This Been Tested?

ResetsProperlyAndReplaysTheSameValues feeds a series, resets, replays it, and compares against a fresh instance. It fails on master and passes with the fix.

The window is narrow enough that one dataset misses it: replaying spy_crsi.csv gives 0 divergences in 568 rows. Across 400 random 140-point series through CRSI(3, 2, 100), 172 of 400 series diverge, 176 of 56000 samples, and the first divergence always falls between sample 100 and 104.

ConnorsRelativeStrengthIndexTests on a clean checkout of this branch: 14 passed. Full QuantConnect.Tests.Indicators with all three reset fixes applied: 2770 passed, 0 failed, 5 skipped.

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>

ComputeNextValue and ComputeTrendStreak both read _previousInput before
they write it, and Reset left it pointing at the last input of the run
that had just ended. The first sample after a reset therefore took the
percent rank branch instead of the seeding branch, putting a real price
change ratio into the rolling window where a new instance puts zero, and
moving the trend streak off zero a sample early. The two disagreed around
the point where the lookback window fills.
@Martin-Molinero
Martin-Molinero merged commit 1e1a5b5 into QuantConnect:master Aug 12, 2026
7 of 8 checks passed

@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!

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.

ConnorsRelativeStrengthIndex.Reset leaves _previousInput set, changing the first sample after a reset

2 participants