I'm trying to build an indicator which detects trends, their possible direction etc. Therefore I created a custom class "TrendDirection" including the method "CalcValues()". This method calls the System Indicator Method "ZigZag". By attempting that I receive the error code CS0120 (in German it says "Für das nicht statische Feld, die Methode oder die Eigenschaft "Indicator.ZigZag(DeviationType, double, bool)" ist ein Objektverweis erforderlich.").
Can anyone help my out how it's possible to access a System Indicator Method from a custom class?
Here's the code of the class (unfortunately the formatting got lost when pasting it):
public class TrendDirection
{
static int[] PosHigh = new int[3];
static int[] PosLow = new int[3];
static double[] PriceHigh = new double[3];
static double[] PriceLow = new double[3];
static bool CalcValues (double ZigZagDevInPercent, int ZigZagLookBackPeriod)
{
PosHigh[0] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).HighBar(0, 1, ZigZagLookBackPeriod);
PosHigh[1] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).HighBar(0, 2, ZigZagLookBackPeriod);
PosHigh[2] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).HighBar(0, 3, ZigZagLookBackPeriod);
PosLow[0] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).LowBar(0, 1, ZigZagLookBackPeriod);
PosLow[1] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).LowBar(0, 2, ZigZagLookBackPeriod);
PosLow[2] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).LowBar(0, 3, ZigZagLookBackPeriod);
if (-1 == PosHigh[0] || -1 == PosHigh[1] || -1 == PosHigh[2] || -1 == PosLow[0] || -1 == PosLow[1] || -1 == PosLow[2])
return false;
PriceHigh[0] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).ZigZagHigh[PosHigh[0]];
PriceHigh[1] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).ZigZagHigh[PosHigh[1]];
PriceHigh[2] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).ZigZagHigh[PosHigh[2]];
PriceLow[0] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).ZigZagLow[PosLow[0]];
PriceLow[1] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).ZigZagLow[PosLow[1]];
PriceLow[2] = ZigZag (DeviationType.Percent, ZigZagDevInPercent, true).ZigZagLow[PosLow[2]];
return true;
}
public bool IsUpwards()
{
// TBD
return false;
}
public bool IsDownwards()
{
// TBD
return false;
}
}
Frederik

Comment