Line Drawing Indicator
Line Drawing Indicator
07 Feb 2021, 20:05
Hi, can someone help me with this indicator. Its not drawing lines on the chart.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class AverageLineforRanging : Indicator
{
private Fractals Frac;
private double Top;
private double Bottom;
protected override void Initialize()
{
Frac = Indicators.Fractals(5);
}
public override void Calculate(int index)
{
if (index == 0)
Displaylineonchart();
}
private void Displaylineonchart()
{
Top = ((Frac.UpFractal.Last(1) + Frac.UpFractal.Last(2) + Frac.UpFractal.Last(3) + Frac.UpFractal.Last(4)) / 4);
Bottom = ((Frac.DownFractal.Last(1) + Frac.DownFractal.Last(2) + Frac.DownFractal.Last(3) + Frac.DownFractal.Last(4)) / 4);
Chart.DrawHorizontalLine("Top", Top, Color.AliceBlue, 5, LineStyle.Solid);
Chart.DrawHorizontalLine("Bottom", Bottom, Color.AliceBlue, 5, LineStyle.Solid);
}
}
}
PanagiotisCharalampous
08 Feb 2021, 08:38
Hi jackhpfilerrowson,
Where do you expect the lines to be drawn? You are trying to draw the lines at index 0 when all the indicator values are NaN.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous