Expected Behavior
After Reset(), an indicator produces the same values on a replay as a fresh instance fed the same bars.
Actual Behavior
SuperTrend.Reset() does not clear _previousClose. ComputeNextValue assigns it on the early return it takes while the ATR warms up, so at ordinary periods the stale value is overwritten before it can be read. At period == 1 the ATR is ready on the first update, that early return never runs, and the trailing-band comparison reads the close carried over from before the reset.
Measured over 400 random series: 400 of 400 diverge at period 1 (2815 of 24000 samples). Period 2 and period 10 give 0 of 400.
Potential Solution
Set _previousClose = 0m in Reset().
Reproducing the Problem
Construct SuperTrend(1, ...), feed it bars, call Reset(), replay the same bars, and compare Current.Value against a fresh instance.
Related: BasicUpperBand, BasicLowerBand, CurrentTrailingUpperBand and CurrentTrailingLowerBand also survive Reset() holding values from the previous run. They never feed back into Current.Value, so they do not change the indicator's output, but a caller reading them after a reset sees stale numbers.
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
SuperTrend.Reset()does not clear_previousClose.ComputeNextValueassigns it on the early return it takes while the ATR warms up, so at ordinary periods the stale value is overwritten before it can be read. Atperiod == 1the ATR is ready on the first update, that early return never runs, and the trailing-band comparison reads the close carried over from before the reset.Measured over 400 random series: 400 of 400 diverge at period 1 (2815 of 24000 samples). Period 2 and period 10 give 0 of 400.
Potential Solution
Set
_previousClose = 0minReset().Reproducing the Problem
Construct
SuperTrend(1, ...), feed it bars, callReset(), replay the same bars, and compareCurrent.Valueagainst a fresh instance.Related:
BasicUpperBand,BasicLowerBand,CurrentTrailingUpperBandandCurrentTrailingLowerBandalso surviveReset()holding values from the previous run. They never feed back intoCurrent.Value, so they do not change the indicator's output, but a caller reading them after a reset sees stale numbers.System Information
macOS, .NET 9,
masterat f0e339c.Checklist
masterbranch