Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/m-r/PivotPoints/PivotPoints.Catalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ public static partial class PivotPoints
.WithMethodName("ToPivotPoints")
.AddEnumParameter<PeriodSize>("windowSize", "Window Size", description: "Size of the window for pivot calculation", isRequired: false, defaultValue: PeriodSize.Month)
.AddEnumParameter<PivotPointType>("pointType", "Point Type", description: "Type of pivot points to calculate", isRequired: false, defaultValue: PivotPointType.Standard)
.AddResult("R5", "Resistance 5", ResultType.Default)
.AddResult("R4", "Resistance 4", ResultType.Default)
.AddResult("R3", "Resistance 3", ResultType.Default)
.AddResult("R2", "Resistance 2", ResultType.Default)
.AddResult("R1", "Resistance 1", ResultType.Default)
.AddResult("PP", "Pivot Point", ResultType.Default, isReusable: true)
.AddResult("S1", "Support 1", ResultType.Default)
.AddResult("S2", "Support 2", ResultType.Default)
.AddResult("S3", "Support 3", ResultType.Default)
.AddResult("S4", "Support 4", ResultType.Default)
.AddResult("S5", "Support 5", ResultType.Default)
.Build();

// Pivot Points Series Listing
Expand Down
18 changes: 18 additions & 0 deletions src/m-r/PivotPoints/PivotPoints.Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ namespace Skender.Stock.Indicators;
/// </summary>
internal interface IPivotPoint
{
/// <summary>
/// Gets the fifth resistance level.
/// </summary>
decimal? R5 { get; }

/// <summary>
/// Gets the fourth resistance level.
/// </summary>
Expand Down Expand Up @@ -49,6 +54,11 @@ internal interface IPivotPoint
/// Gets the fourth support level.
/// </summary>
decimal? S4 { get; }

/// <summary>
/// Gets the fifth support level.
/// </summary>
decimal? S5 { get; }
}

/// <summary>
Expand All @@ -73,6 +83,8 @@ public record PivotPointsResult : IPivotPoint, ISeries
public decimal? S3 { get; init; }
/// <inheritdoc/>
public decimal? S4 { get; init; }
/// <inheritdoc/>
public decimal? S5 { get; init; }

/// <inheritdoc/>
public decimal? R1 { get; init; }
Expand All @@ -82,6 +94,8 @@ public record PivotPointsResult : IPivotPoint, ISeries
public decimal? R3 { get; init; }
/// <inheritdoc/>
public decimal? R4 { get; init; }
/// <inheritdoc/>
public decimal? R5 { get; init; }
}

/// <summary>
Expand All @@ -100,6 +114,8 @@ internal record WindowPoint : IPivotPoint
public decimal? S3 { get; init; }
/// <inheritdoc/>
public decimal? S4 { get; init; }
/// <inheritdoc/>
public decimal? S5 { get; init; }

/// <inheritdoc/>
public decimal? R1 { get; init; }
Expand All @@ -109,6 +125,8 @@ internal record WindowPoint : IPivotPoint
public decimal? R3 { get; init; }
/// <inheritdoc/>
public decimal? R4 { get; init; }
/// <inheritdoc/>
public decimal? R5 { get; init; }
}


Expand Down
20 changes: 16 additions & 4 deletions src/m-r/PivotPoints/PivotPoints.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ PivotPointsResult r
S2 = windowPoint.S2,
S3 = windowPoint.S3,
S4 = windowPoint.S4,
S5 = windowPoint.S5,

// resistance
R1 = windowPoint.R1,
R2 = windowPoint.R2,
R3 = windowPoint.R3,
R4 = windowPoint.R4
R4 = windowPoint.R4,
R5 = windowPoint.R5,
}
: new PivotPointsResult {
Timestamp = q.Timestamp
Expand Down Expand Up @@ -175,9 +177,13 @@ private static WindowPoint GetPivotPointStandard(
S1 = (pp * 2) - high,
S2 = pp - (high - low),
S3 = low - (2 * (high - pp)),
S4 = low - (3 * (high - pp)),
S5 = low - (4 * (high - pp)),
R1 = (pp * 2) - low,
R2 = pp + (high - low),
R3 = high + (2 * (pp - low))
R3 = high + (2 * (pp - low)),
R4 = high + (3 * (pp - low)),
R5 = high + (4 * (pp - low))
Comment on lines +182 to +188
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify Standard pivot formulas against the reference source.

The formulas follow a consistent mathematical pattern extending R3/S3, but should be verified against the referenced Classic Pivot Points definition to ensure correctness.


🌐 Web query:

What are the formulas for R4, R5, S4, and S5 in Classic/Standard pivot points according to mypivots.com?

💡 Result:

Classic (Standard) pivot formulas on MyPivots:

  • PP = (HIGH + LOW + CLOSE) / 3. [1]
  • RANGE = HIGH − LOW. [1]
  • R1 = (2 * PP) − LOW. [1]
  • R2 = PP + RANGE. [1]
  • R3 = R2 + RANGE = PP + 2 * RANGE. [1]
  • R4 = R3 + RANGE = PP + 3 * RANGE. [1]
  • S1 = (2 * PP) − HIGH. [1]
  • S2 = PP − RANGE. [1]
  • S3 = S2 − RANGE = PP − 2 * RANGE. [1]
  • S4 = S3 − RANGE = PP − 3 * RANGE. [1]

MyPivots' Classic definition lists R1–R4 and S1–S4 only; it does not provide R5 or S5 for the Classic/Standard set. [1][2]

Sources: MyPivots Classic Pivot Points definition and Pivot Point Calculator. [1][2]


Critical formula errors in Standard pivot point calculations—R3, R4, S4 do not match reference; R5/S5 should not exist.

The code's formulas diverge from the MyPivots Classic/Standard definition. R3 should be PP + 2 * RANGE, not high + (2 * (pp - low)). Similarly, R4 = PP + 3 * RANGE, and S4 = PP − 3 * RANGE. Additionally, MyPivots' Classic definition lists R1–R4 and S1–S4 only; it does not provide R5 or S5 for the Classic/Standard set, so these should be removed.

Lines 182–188 require correction to align with the authoritative reference formulas.

🤖 Prompt for AI Agents
In src/m-r/PivotPoints/PivotPoints.StaticSeries.cs around lines 182–188 the
pivot formulas are incorrect and include extra levels R5/S5; replace them so the
Classic/Standard set only computes R1–R4 and S1–S4 using RANGE = high - low and
PP = pp: R1 = (pp * 2) - low, R2 = pp + RANGE, R3 = pp + 2 * RANGE, R4 = pp + 3
* RANGE, S1 = (pp * 2) - high, S2 = pp - RANGE, S3 = pp - 2 * RANGE, S4 = pp - 3
* RANGE; remove any R5 and S5 entries and adjust any surrounding code/exports
that referenced R5/S5.

};
}

Expand All @@ -196,10 +202,12 @@ private static WindowPoint GetPivotPointCamarilla(
S2 = close - (1.1m / 6 * (high - low)),
S3 = close - (1.1m / 4 * (high - low)),
S4 = close - (1.1m / 2 * (high - low)),
S5 = close - (1.1m / 1 * (high - low)),
R1 = close + (1.1m / 12 * (high - low)),
R2 = close + (1.1m / 6 * (high - low)),
R3 = close + (1.1m / 4 * (high - low)),
R4 = close + (1.1m / 2 * (high - low))
R4 = close + (1.1m / 2 * (high - low)),
R5 = close + (1.1m / 1 * (high - low)),
Comment on lines +207 to +212
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify Camarilla pivot formulas against the reference source.

The S5/R5 formulas use the multiplier 1.1 (from 1.1/1), which extends the Camarilla pattern. Please confirm this matches the referenced Camarilla Pivot Points definition.


🌐 Web query:

What are the formulas for R5 and S5 in Camarilla pivot points according to mypivots.com?

💡 Result:

MyPivots.com lists Camarilla pivots only through R4 and S4 — it does not provide formulas for R5 or S5. The site gives:

  • R4 = C + RANGE * 1.1/2
  • R3 = C + RANGE * 1.1/4
  • R2 = C + RANGE * 1.1/6
  • R1 = C + RANGE * 1.1/12
  • PP = (HIGH + LOW + CLOSE) / 3
  • S1 = C - RANGE * 1.1/12
  • S2 = C - RANGE * 1.1/6
  • S3 = C - RANGE * 1.1/4
  • S4 = C - RANGE * 1.1/2

(Where RANGE = HIGH − LOW and C = Close.) [1]

Source: MyPivots — “Camarilla Pivot Points.” [1]


Update GetPivotPointCamarilla R5/S5 formulas to match standard Camarilla implementation.

The fifth layer of Camarilla formulas can vary depending on which version is used, but the code's R5/S5 implementation differs from industry standards. Standard Camarilla implementations define R5 = R4 + 1.168 * (R4 - R3) and S5 = S4 - 1.168 * (S3 - S4), or alternatively R5 = (High/Low) * Close and S5 = Close - (R5 - Close). The code currently uses close ± 1.1 * (high - low), which extends the 1.1/x multiplier pattern but does not align with documented Camarilla variants. Additionally, the cited MyPivots.com reference only defines levels through R4/S4.

Replace the R5/S5 formulas with the standard formula-based approach or document the custom variant rationale.

🤖 Prompt for AI Agents
In src/m-r/PivotPoints/PivotPoints.StaticSeries.cs around lines 207-212, the
R5/S5 Camarilla formulas currently use close ± 1.1*(high-low) which does not
match standard Camarilla definitions; replace the R5/S5 assignments with the
standard Camarilla formula: set R5 = R4 + 1.168m * (R4 - R3) and S5 = S4 -
1.168m * (S3 - S4) (ensure you reference the already-computed R3/R4 and S3/S4
values and use decimal literals with the m suffix), or alternatively implement
the (High/Low)*Close variant if you prefer that documented approach; update any
comments to indicate which Camarilla variant is used.

};

/// <summary>
Expand Down Expand Up @@ -243,9 +251,13 @@ private static WindowPoint GetPivotPointFibonacci(
S1 = pp - (0.382m * (high - low)),
S2 = pp - (0.618m * (high - low)),
S3 = pp - (1.000m * (high - low)),
S4 = pp - (1.618m * (high - low)),
S5 = pp - (2.618m * (high - low)),
R1 = pp + (0.382m * (high - low)),
R2 = pp + (0.618m * (high - low)),
R3 = pp + (1.000m * (high - low))
R3 = pp + (1.000m * (high - low)),
R4 = pp + (1.618m * (high - low)),
R5 = pp + (2.618m * (high - low)),
Comment on lines +256 to +262
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify Fibonacci pivot formulas against the reference source.

The formulas use Fibonacci extension ratios 1.618 and 2.618, which are standard. However, please verify these match the referenced Fibonacci Pivot Points definition. Note: The PR description references the Woodie URL (definition/228) for Fibonacci verification—please confirm the correct reference URL.


🌐 Web query:

What are the formulas for R4, R5, S4, and S5 in Fibonacci pivot points?

💡 Result:

Use the standard pivot (PP) and the prior-day range (DR):

PP = (High + Low + Close) / 3
DR = High - Low

Fibonacci extensions:

  • R4 = PP + 1.382 * DR. [1]
  • R5 = PP + 1.618 * DR. [1]
  • S4 = PP - 1.382 * DR. [1]
  • S5 = PP - 1.618 * DR. [1]

(These ratios are the common Fibonacci extension multipliers used for R4/R5 and S4/S5.) [1][2]

Sources: Sierra Chart pivot formulas; TradingView Fibonacci pivot implementation. [1][2]


Fix Fibonacci pivot formulas—ratios are incorrect.

The formulas use wrong Fibonacci extension ratios. According to standard Fibonacci pivot implementations:

  • R4 and S4 should use 1.382, not 1.618
  • R5 and S5 should use 1.618, not 2.618

Corrected formulas (lines 256-262):

S4 = pp - (1.382m * (high - low)),
S5 = pp - (1.618m * (high - low)),
R1 = pp + (0.382m * (high - low)),
R2 = pp + (0.618m * (high - low)),
R3 = pp + (1.000m * (high - low)),
R4 = pp + (1.382m * (high - low)),
R5 = pp + (1.618m * (high - low)),
🤖 Prompt for AI Agents
In src/m-r/PivotPoints/PivotPoints.StaticSeries.cs around lines 256 to 262 the
Fibonacci extension ratios are wrong: R4/S4 currently use 1.618 and R5/S5 use
2.618; update the constants so S4 = pp - (1.382m * (high - low)), S5 = pp -
(1.618m * (high - low)), R1 = pp + (0.382m * (high - low)), R2 = pp + (0.618m *
(high - low)), R3 = pp + (1.000m * (high - low)), R4 = pp + (1.382m * (high -
low)), R5 = pp + (1.618m * (high - low)) to reflect standard Fibonacci pivot
ratios.

};
}

Expand Down
4 changes: 3 additions & 1 deletion src/m-r/RollingPivots/RollingPivots.BufferList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ public void Add(IQuote quote)
S2 = wp.S2,
S3 = wp.S3,
S4 = wp.S4,
S5 = wp.S5,
R1 = wp.R1,
R2 = wp.R2,
R3 = wp.R3,
R4 = wp.R4
R4 = wp.R4,
R5 = wp.R5,
};
}
else
Expand Down
10 changes: 10 additions & 0 deletions src/m-r/RollingPivots/RollingPivots.Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public record RollingPivotsResult : ISeries, IPivotPoint
/// </summary>
public decimal? S4 { get; init; }

/// <summary>
/// Gets the fifth support level (S5).
/// </summary>
public decimal? S5 { get; init; }

/// <summary>
/// Gets the first resistance level (R1).
/// </summary>
Expand All @@ -55,4 +60,9 @@ public record RollingPivotsResult : ISeries, IPivotPoint
/// Gets the fourth resistance level (R4).
/// </summary>
public decimal? R4 { get; init; }

/// <summary>
/// Gets the fifth resistance level (R5).
/// </summary>
public decimal? R5 { get; init; }
}
4 changes: 3 additions & 1 deletion src/m-r/RollingPivots/RollingPivots.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ public static IReadOnlyList<RollingPivotsResult> ToRollingPivots(
S2 = wp.S2,
S3 = wp.S3,
S4 = wp.S4,
S5 = wp.S5,

// resistance
R1 = wp.R1,
R2 = wp.R2,
R3 = wp.R3,
R4 = wp.R4
R4 = wp.R4,
R5 = wp.R5,
};
}
else
Expand Down
Loading