[HandlerName("T3Tilson MA")] [HandlerCategory("vvAverages")] public class T3Tilson : IDouble2DoubleHandler, IContextUses { /* _T3Average * By Bob Fulks, modified by Alex Matulich 4/2003 * * The T3 Average is essentially a low-pass filter, as are the traditional moving average * and exponential moving average. The T3 Average, however, exhibits a steeper rolloff, * resulting in better filtering of high-frequency noise while better preserving the * low-frequency components of a time series. * * This function is an EasyLanguage version of the algorithm described in the January * 1998 issue of TASC, p57, "Smoothing Techniques for More Accurate Signals" by Tim * Tillson. It is translated from the MetaStock code presented in the article. * The function allows a variable length as input. * * The variable b (also called "Hot") is a damping coefficient. The suggested value of * b is 0.7, but this value slightly amplifies low-frequency components. b=0.5 seems * better for having a flat response at low frequencies. A smaller value of b will * result in too much attenuation of low frequencies. * * The Length parameter is divided by two to make the T3 Average's lag equivalent to * the lag of the traditional moving averages. This way you can use the T3 Average as * a drop-in replacement for Average or xAverage, and get the same lag but better * noise filtering. * * The variable "b" is substituted for the variable "a" used in the article since "a" * is a reserved word. */ [HandlerParameter(true, "10", Min = "5", Max = "100", Step = "5")] public int Period { get; set; } [HandlerParameter(true, "1", Min = "0", Max = "2", Step = "0.1")] public double VolumeFactor { get; set; } public IList Execute(IList src) { var P = src; var gd1 = new double[P.Count]; var EMA1 = Context.GetData("ema1", new[] { "ema1"+Period.ToString() }, () => EMA.EMA_TSLab(P, Period)); var EMA2 = Context.GetData("ema2", new[] { "ema2"+Period.ToString() }, () => EMA.EMA_TSLab(EMA1, Period)); for (int i = 0; i < P.Count; i++) { gd1[i] = EMA1[i] * (1 + VolumeFactor) - EMA2[i] * VolumeFactor; } var t3i1 = new double[P.Count]; var EMA3 = EMA.EMA_TSLab(gd1, Period); var EMA4 = EMA.EMA_TSLab(EMA3, Period); for (int i = 0; i < P.Count; i++) { t3i1[i] = EMA3[i] * (1 + VolumeFactor) - EMA4[i] * VolumeFactor; } var t3i2 = new double[P.Count]; var EMA5 = EMA.EMA_TSLab(t3i1, Period); var EMA6 = EMA.EMA_TSLab(EMA5, Period); for (int i = 0; i < P.Count; i++) { t3i2[i] = EMA5[i] * (1 + VolumeFactor) - EMA6[i] * VolumeFactor; } return t3i2; } public IContext Context { get; set; } }