I am currently programming an indi that draws horizontal lines at pivot highs and pivot lows.
To not clutter up, found pivots are rounded to one decimal. So a pivot found at 86.23 will be drawn at 86.20 etc.
I have defined a pivot as the highest high or lowest low of 7 consecutive bars.
As you can see in the attached screenshot numerous pivots are found, the thin red and green lines.
I drew in the thick brown lines myself, as these are also pivots indicated by the circles. But the program is not recognizing them as such.
The big question I have is why are these pivots not found by the program?
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
//SR.Set(Close[0]);
if (CurrentBar < 3) return;
for (int i = 3; i <= CurrentBar; i++)
{
if (IsPivotHigh(i))
{
ResistanceList.Add(Math.Round(High[i],Interval));
}
if (IsPivotLow(i)) SupportList.Add(Math.Round(Low[i],Interval));
}
DrawResistanceLines();
DrawSupportLines();
}
private bool IsPivotHigh(int i)
{
if ( High[i] >= High[i - 1]
&& High[i] >= High[i - 2]
&& High[i] >= High[i - 3]
&& High[i] >= High[i + 1]
&& High[i] >= High[i + 2]
&& High[i] >= High[i + 3] )
{
return true;
}
return false;
}
private bool IsPivotLow(int i)
{
if ( Low[i] <= Low[i - 1]
&& Low[i] <= Low[i - 2]
&& Low[i] <= Low[i - 3]
&& Low[i] <= Low[i + 1]
&& Low[i] <= Low[i + 2]
&& Low[i] <= Low[i + 3] )
{
return true;
}
return false;
}
Comment