Description
Indicator to determine the Higher Highs, Lower Lows, Lower Highs and Higher Lows. Takes period as a parameter. The higher the rougher the Pivot Points.
Feel free to buy me a coffee if i helped you out ^^
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true)]
public class PivotPoints : Indicator
{
[Parameter("Period", DefaultValue = 3)]
public int Period { get; set; }
[Output("HigherHigh", PlotType = PlotType.Points, Thickness = 20, Color = Colors.Blue)]
public IndicatorDataSeries hh { get; set; }
[Output("HigherLow", PlotType = PlotType.Points, Thickness = 20, Color = Colors.Yellow)]
public IndicatorDataSeries hl { get; set; }
[Output("LowerLow", PlotType = PlotType.Points, Thickness = 20, Color = Colors.Red)]
public IndicatorDataSeries ll { get; set; }
[Output("LowerHigh", PlotType = PlotType.Points, Thickness = 20, Color = Colors.Orange)]
public IndicatorDataSeries lh { get; set; }
public double PivotHigh { get; private set; } = double.NaN;
public double PivotLow { get; private set; } = double.NaN;
public double HigherHigh { get; private set; } = double.NaN;
public double LowerHigh { get; private set; } = double.NaN;
public double HigherLow { get; private set; } = double.NaN;
public double LowerLow { get; private set; } = double.NaN;
public override void Calculate(int index)
{
index -= Period;
if (index < Period) return;
var isHighPivot = true;
var isLowPivot = true;
for (var i = index - Period; i <= index + Period; i++)
{
if (i != index)
{
if (MarketSeries.High[i] >= MarketSeries.High[index])
{
isHighPivot = false;
}
if (MarketSeries.Low[i] <= MarketSeries.Low[index])
{
isLowPivot = false;
}
}
}
PivotHigh = isHighPivot ? MarketSeries.High[index] : double.NaN;
PivotLow = isLowPivot ? MarketSeries.Low[index] : double.NaN;
// Determine pivot point types
if (!double.IsNaN(PivotHigh))
{
if (double.IsNaN(HigherHigh) || PivotHigh > HigherHigh)
{
HigherHigh = PivotHigh;
hh[index] = HigherHigh;
}
else if (PivotHigh < HigherHigh)
{
LowerHigh = PivotHigh;
lh[index] = LowerHigh;
}
}
if (!double.IsNaN(PivotLow))
{
if (double.IsNaN(LowerLow) || PivotLow < LowerLow)
{
LowerLow = PivotLow;
ll[index] = LowerLow;
}
else if (PivotLow > LowerLow)
{
HigherLow = PivotLow;
hl[index] = HigherLow;
}
}
}
}
}
DE
Descy
Joined on 01.07.2023
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Best Pivots.algo
- Rating: 5
- Installs: 1708
- Modified: 06/07/2023 13:38
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.