Skip to content

Feature : Implements Parabolic SAR Extended (SAREXT) #8818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SaiRevanth25
Copy link

@SaiRevanth25 SaiRevanth25 commented Jun 9, 2025

Description

Implements Parabolic SAR Extended (SAREXT) Indicator

Related Issue

#6987 Reference PR - #7528

How Has This Been Tested?

Comparison against talib generated data for SAREXT - spy_sarext.csv

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

Copy link
Collaborator

@jhonabreul jhonabreul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! It's looking good. Leaving a few minor comments

Comment on lines 121 to 122
if (_sarInit != 0)
return Math.Abs(_sarInit); // Force SAR to be non-negative to maintain compatibility with SAR logic assumptions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this comment about using Abs here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extended version can return negative values to indicate the short positioning, but the -ve values are handled in HandleLongPosition and HandleShortPosition. so removing this, thanks.

if (Samples == 2)
{
Init(input);
_previousBar = input;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this comment about _previousBar. Should it be returning here right away? Or just not set the previous bar at this point?

Copy link
Author

@SaiRevanth25 SaiRevanth25 Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if _previousBar is not set before calling HandleLongPosition or HandleShortPosition , the tests break because those methods rely on _previousBar being initialized.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, but _previousBar is set when the first sample comes in. The issue is that on sample 2, HandleLongPosition and HandleShortPosition will use input both as previous and current input, does that make sense?

Copy link
Author

@SaiRevanth25 SaiRevanth25 Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhonabreul On the second sample, using input as both the current and previous bar is intentional, it's part of the warm-up phase where trend direction and initial values are set (i.e., indicator initialization). Real SAR calculations begin from sample 3 (Samples >= 3), where _previousBar and input truly differ. The indicator is marked IsReady only after two samples.

@SaiRevanth25 SaiRevanth25 requested a review from jhonabreul June 16, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants