Clear ConnorsRelativeStrengthIndex._previousInput on reset - #9687
Merged
Martin-Molinero merged 1 commit intoAug 12, 2026
Merged
Conversation
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.
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ConnorsRelativeStrengthIndex.Reset()did not clear_previousInput. BothComputeNextValueandComputeTrendStreakread 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?
ResetsProperlyAndReplaysTheSameValuesfeeds a series, resets, replays it, and compares against a fresh instance. It fails onmasterand passes with the fix.The window is narrow enough that one dataset misses it: replaying
spy_crsi.csvgives 0 divergences in 568 rows. Across 400 random 140-point series throughCRSI(3, 2, 100), 172 of 400 series diverge, 176 of 56000 samples, and the first divergence always falls between sample 100 and 104.ConnorsRelativeStrengthIndexTestson a clean checkout of this branch: 14 passed. FullQuantConnect.Tests.Indicatorswith all three reset fixes applied: 2770 passed, 0 failed, 5 skipped.Types of changes
Checklist:
bug-<issue#>-<description>