Skip to content

fix(momentum): use a neutral IBS value for flat bars - #540

Merged
cinar merged 3 commits into
cinar:masterfrom
jackiectl2:fix-flat-bar-ibs-neutral
Nov 24, 2026
Merged

cinar merged 3 commits into
cinar:masterfrom
jackiectl2:fix-flat-bar-ibs-neutral

Conversation

@jackiectl2

Copy link
Copy Markdown
Contributor

Describe Request

A flat bar (High == Low) has no location within its high-low range, but InternalBarStrength currently returns 0 for it, the same value as a close at the low. This change returns the neutral midpoint 0.5 instead and documents it. The regenerated momentum/README.md picks up the doc comment.

Fixes #532.

Change Type

Bug fix with a regression test.

  • TestInternalBarStrengthZeroDenom now expects 0.5, and a new float32 test mixes flat and ordinary bars. Both fail on master and pass with the change; ibs.go stays at 100% coverage.
  • Ran the task steps locally with Go 1.22 (the version in go.mod that CI uses): go fix, go vet, gosec v2.20.0, staticcheck v0.5.1 and revive v1.3.4 report nothing; go test -race ./... passes; gomarkdoc only changes momentum/README.md.

Checklist

  • I have read and agree to the Contributor License Agreement (CLA).
  • My code adheres to the project's coding standards and includes comprehensive unit tests.
  • No external dependencies have been introduced.

A flat bar has no location within its high-low range. Return the neutral midpoint 0.5 rather than the low endpoint 0; cover float32 and float64 streams with flat and ordinary bars.

Fixes cinar#532.

Signed-off-by: Tianlang (Jackie) Chen <305351710+jackiectl2@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@jackiectl2

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 20, 2026
@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.83%. Comparing base (5c05d1e) to head (b03034b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #540   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files         240      240           
  Lines        7843     7843           
=======================================
  Hits         7203     7203           
  Misses        548      548           
  Partials       92       92           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cinar
cinar force-pushed the fix-flat-bar-ibs-neutral branch from 5662b04 to b03034b Compare November 24, 2026 15:54
@cinar
cinar merged commit 7017344 into cinar:master Nov 24, 2026
2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IBS returns 0 instead of 0.5 when High equals Low

3 participants