Clear SuperTrend._previousClose on reset - #9688
Merged
Martin-Molinero merged 1 commit intoAug 12, 2026
Merged
Conversation
ComputeNextValue assigns _previousClose on the early return it takes while the average true range warms up. A period of one leaves the average true range ready on the first update, so that early return never runs and the trailing band comparison reads the close carried over from before the reset.
11 tasks
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
SuperTrend.Reset()did not clear_previousClose.Related Issue
Fixes #9685.
Motivation and Context
ComputeNextValueassigns_previousCloseon the early return it takes while the ATR warms up, so at ordinary periods the stale value is overwritten before anything reads it. A period of one leaves the ATR ready on the first update, that early return never runs, and the trailing-band comparison reads the close carried over from before the reset.Across 400 random series: 400 of 400 diverge at period 1, 2815 of 24000 samples. Period 2 and period 10 give 0 of 400, which is why this survived until the period was varied.
Requires Documentation Change
No.
How Has This Been Tested?
ResetsProperlyWithPeriodOnebuildsSuperTrend(1, ...), feeds it, resets, replays, and compares against a fresh instance. It fails onmasterand passes with the fix.SuperTrendTestson a clean checkout of this branch: 13 passed. FullQuantConnect.Tests.Indicatorswith all three reset fixes applied: 2770 passed, 0 failed, 5 skipped.Not changed here:
BasicUpperBand,BasicLowerBand,CurrentTrailingUpperBandandCurrentTrailingLowerBandalso surviveReset()holding values from the previous run. They never feed back intoCurrent.Value, so the indicator's output is unaffected and clearing them is a wider change than this one line. Noted on the issue.Types of changes
Checklist:
bug-<issue#>-<description>