Profile Picture

TEMA (or DEMA or EMA) of Generic List?

Posted By rterbush 7 Years Ago
Message
Posted Monday July 05 2010
Working on constructing Heikin Ashi values and trying to derive TEMA of a Generic List.

These indicators seem to insist on iSeries as input. Any way to convince them otherwise?

New to RE and new to C#.

Posted Tuesday July 06 2010
I'm assuming that you're looking to pass them a list of doubles? There really isn't a way to force it unless you derive. So derive your own indicator from TEMA, for example, and create a constructor that takes a list of doubles.

Inside of your derived class, have a class that massages the list of doubles into an ISeries derived class.

If you need help with that, let me know.

rterbush (7/5/2010)
Working on constructing Heikin Ashi values and trying to derive TEMA of a Generic List.

These indicators seem to insist on iSeries as input. Any way to convince them otherwise?

New to RE and new to C#.

Posted Tuesday July 06 2010
Actually, see this post.
ISeries double class sample
Posted Tuesday July 06 2010
Bill,

I have started with the following but am a little confused. Do I need to put methods for List or TEMA in this code? Very green here so may need a little more of a nudge.

Tks


protected override class TEMA : int, IList
{
List myTEMA = new List();
public SeriesChartSettings ChartSettings { get; set; }

public double LookBack(int nBars)
{
return myTEMA[myTEMA. - nBars];
}

public double Current
{
get { return myTEMA[myTEMA.Count - 1]; }
}

public int Count
{
get { return myTEMA.Count; }
}

public bool OldValuesChange
{
get { return false; }
}
public int OldestValueChanged
{
get { return 0; }
}
}

Posted Thursday July 08 2010
You need to derive from ISeries, not IList.
Posted Thursday July 08 2010
So I have gotten as far as the below. Not entirely sure yet if this is sufficient as I am not sure quite how TEMA will operate on the List. This has quieted the syntax checker but not sure if it accomplishes the goal yet.



public class TEMA : ISeries
{
private int period;
List myTEMA = new List();

public TEMA(int period, List myTEMA)
: base()
{
this.period = 0;

// move double to ISeries
}

public SeriesChartSettings ChartSettings { get; set; }

public double LookBack(int nBars)
{
return myTEMA[myTEMA.Count - nBars];
}

public double Average
{
get { return myTEMA[myTEMA.Count - 1]; }
}

public int Count
{
get { return myTEMA.Count; }
}

public bool OldValuesChange
{
get { return false; }
}
public int OldestValueChanged
{
get { return 0; }
}
}

Posted Thursday July 08 2010
I could sure use some help here. Maybe I am doing something wrong, but it seems nearly any indicator I want to write needs to do what I am trying to accomplish here. Would sure be helpful if this was a well documented case.

Here is what I have and have completely hit a wall. The indicator is erroring out when it hits myTEMA.Current. Count is zero. Obviously no data being associated with this overload. Not clear to me how to pass that Generic List and how to calculate TEMA on it.

This is the last bits holding me up. Would appreciate any guidance that gets me to enlightenment.


public class MyTEMA : ISeries
{
List myTEMA = new List();

public MyTEMA(int period, List myTEMA)
: base()
{
return;
}

public SeriesChartSettings ChartSettings { get; set; }

public double LookBack(int nBars)
{
return myTEMA[myTEMA.Count - nBars];
}

public double Current
{
get { return myTEMA[myTEMA.Count - 1]; }
}

public int Count
{
get { return myTEMA.Count; }
}

public bool OldValuesChange
{
get { return false; }
}
public int OldestValueChanged
{
get { return 0; }
}
}
Posted Friday July 09 2010
This continues to evolve and I am successfully populating data structures, but appears there is no TEMA processing of the numbers. The next step here is just to complete this with the TEMA algorithm, but I don't think that was what was intended if I understand correctly.


public class TEMA : ISeries
{
List myTEMA = new List();

public TEMA(int period, List newList)
: base()
{
myTEMA = newList;
}

public SeriesChartSettings ChartSettings { get; set; }

public double LookBack(int nBars)
{
return myTEMA[myTEMA.Count - (nBars +1)];
}

public double Current
{
get { return myTEMA[myTEMA.Count - 1]; }
}

public int Count
{
get { return myTEMA.Count; }
}

public bool OldValuesChange
{
get { return false; }
}
public int OldestValueChanged
{
get { return 0; }
}
}
Posted Friday July 09 2010
I've attached a trading system that will implement an ISeries based on custom values. Then the trading system demonstrates populating that ISeries and passing that custom collection as an input to an indicator.

Attachments
IndicatorCustomSeries.zip (315 views, 10.00 KB)
Posted Friday July 09 2010
Thanks Bill, good stuff.

How is this different if I am trying to use MySeries in an indicator which is SeriesCalculatorBaseWithValues?

Anything important to know before you go away for the weekend? :-)


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems