Skip to content
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

adjust PSAR validation #1030

Merged
merged 2 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/_indicators/ParabolicSar.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ IEnumerable<ParabolicSarResult> results =

**`maxAccelerationFactor`** _`double`_ - Maximum factor limit. Must be greater than `accelerationStep`. Default is 0.2

**`initialFactor`** _`double`_ - Optional. Initial Acceleration Factor. Must be greater than 0. Default is `accelerationStep`.
**`initialFactor`** _`double`_ - Optional. Initial Acceleration Factor. Must be greater than 0 and not larger than `maxAccelerationFactor`. Default is `accelerationStep`.

### Historical quotes requirements

Expand Down
6 changes: 3 additions & 3 deletions src/m-r/ParabolicSar/ParabolicSar.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ public static partial class Indicator
{
string message = string.Format(
EnglishCulture,
"Acceleration Step must be smaller than provided Max Acceleration Factor ({0}) for Parabolic SAR.",
"Acceleration Step cannot be larger than the Max Acceleration Factor ({0}) for Parabolic SAR.",
maxAccelerationFactor);

throw new ArgumentOutOfRangeException(nameof(accelerationStep), accelerationStep, message);
}

if (initialFactor <= 0 || initialFactor >= maxAccelerationFactor)
if (initialFactor <= 0 || initialFactor > maxAccelerationFactor)
{
throw new ArgumentOutOfRangeException(nameof(initialFactor), initialFactor,
"Initial Step must be greater than 0 and less than Max Acceleration Factor for Parabolic SAR.");
"Initial Factor must be greater than 0 and not larger than Max Acceleration Factor for Parabolic SAR.");
}
}
}
2 changes: 1 addition & 1 deletion tests/indicators/m-r/ParabolicSar/ParabolicSar.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void InsufficientQuotes()
public void BadData()
{
List<ParabolicSarResult> r = badQuotes
.GetParabolicSar()
.GetParabolicSar(0.2, 0.2, 0.2)
.ToList();

Assert.AreEqual(502, r.Count);
Expand Down