feat(Delta): add average delta line (SMA/EMA) over the delta histogram - #175
Open
AlbertoAmadorBelchistim wants to merge 2 commits into
Open
AlbertoAmadorBelchistim wants to merge 2 commits into
AlbertoAmadorBelchistim wants to merge 2 commits into
Conversation
Collaborator
|
The moving-average calculation needs correction before merge. |
Adds a configurable moving average overlay on the delta series: - AverageMode enum (SMA / EMA), localized via existing Strings keys. - AverageColorMode enum (Fixed / Zero cross / Slope) controlling the per-bar line color: fixed base color, sign-based, or slope-based. - Properties in a new Average group on the Visualization tab, tagged with [Tab] to follow the settings categorization: ShowAverage, AveragePeriod, AvgMode, AvgColorMode, AverageColor, AvgSlopeUpColor, AvgSlopeDownColor, AverageWidth. - Property names, group and tab reuse existing localization resources (Strings.ShowAverage, Strings.Average, Strings.AveragePeriod, Strings.CalculationMode, Strings.SMA, Strings.EMA, Strings.Width). The four color-mode strings and three enum member names have no matching keys in OFT.Localization yet, so they are declared inline, ready to be swapped to resource keys once they exist. - O(1) rolling SMA (queue + running sum) and standard EMA with state reset at bar 0; no look-ahead. - Hidden by default; the series is appended at the end of DataSeries, so existing templates are unaffected.
OnCalculate runs repeatedly for the forming bar. The SMA enqueued every call as a new sample and the EMA advanced its state on every call, so the live values depended on the number of updates a bar received. Both averages are now computed from per-bar values only: the input is stored by bar index, the SMA keeps a running sum per bar and the EMA starts from the stored value of the previous bar. Recalculating the forming bar any number of times gives the same result as a full historical recalculation. The inline UI strings are replaced with existing localization keys. The color options follow the built-in SMA/EMA indicators (Colored direction with bullish and bearish colors); the line color and width are set on the series itself.
AlbertoAmadorBelchistim
force-pushed
the
feat/delta-average-line
branch
from
September 20, 2026 09:37
e779427 to
840dc44
Compare
Contributor
Author
|
Thanks, fixed:
|
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.
Summary
Adds an optional moving average overlay on the Delta histogram, hidden by default.
Implementation notes
Localization
Property names, group and tab reuse existing resources: Strings.ShowAverage, Strings.Average, Strings.AveragePeriod, Strings.CalculationMode, Strings.SMA, Strings.EMA, Strings.Width.
The color-mode strings have no matching keys in OFT.Localization yet, so they are declared inline following the same transitional pattern as the Half Gap settings in DailyLines, ready to be swapped once keys exist:
Testing
Built against Alpha configuration with 0 errors. Smoke-tested on chart: toggle on/off, SMA↔EMA switch, all three color modes, period bounds (1 and 1000).