Ejemplo n.º 1
0
        public HTDCPhase(DataSeries ds, string description)
            : base(ds, description)
        {
            DataSeries Result = new DataSeries(ds, "Result");
            DataSeries Value = HTPeriod.Series(ds);
            double     RealPart = 0; double ImagPart = 0;

            for (int bar = 1; bar < ds.Count; bar++)
            {
                RealPart = 0;
                ImagPart = 0;

                for (int Count = 0; Count < Math.Truncate(Value[bar]); Count++)
                {
                    if ((bar - Count) >= 0)
                    {
                        RealPart += Math.Sin(DegreeToRadian(360 * Count / Value[bar])) * ds[bar - Count];
                        ImagPart += Math.Cos(DegreeToRadian(360 * Count / Value[bar])) * ds[bar - Count];
                    }
                }

                if (Math.Abs(ImagPart) > 0.001)
                {
                    Result[bar] = Math.Atan(RealPart / ImagPart)
                                  * 180 / Math.PI; // Where WL4 required degrees, .NET uses radians!
                }
                if (Math.Abs(ImagPart) <= 0.001)
                {
                    Result[bar] = 90 * Math.Sign(RealPart);
                }

                if ((Value[bar] < 30) & (Value[bar] > 0))
                {
                    @Result[bar] += (6.818 / Value[bar] - 0.227) * 360;
                }

                @Result[bar] += 90;

                if (ImagPart < 0)
                {
                    Result[bar] += 180;
                }
                if (Result[bar] > 315)
                {
                    Result[bar] -= 360;
                }

                base[bar] = Result[bar];
            }
        }
Ejemplo n.º 2
0
        public HTTrendLine(DataSeries ds, string description)
            : base(ds, description)
        {
            DataSeries Period = HTPeriod.Series(ds);

            var rangePartitioner = Partitioner.Create(1, ds.Count);

            Parallel.ForEach(rangePartitioner, (range, loopState) =>
            {
                for (int bar = range.Item1; bar < range.Item2; bar++)
                {
                    base[bar] = Community.Indicators.FastSMA.Series(ds, (int)Math.Truncate(Period[bar]) + 2)[bar];
                }
            });
        }
Ejemplo n.º 3
0
        public HTInstTrendLine(DataSeries ds, string description)
            : base(ds, description)
        {
            DataSeries Result   = new DataSeries(ds, "Result");
            DataSeries DC       = HTPeriod.Series(ds);
            DataSeries Value1ht = new DataSeries(ds, "Value1ht");
            DataSeries Value2ht = new DataSeries(ds, "Value2ht");

            for (int bar = 4; bar < ds.Count; bar++)
            {
                if (DC[bar] != 0)
                {
                    Value1ht[bar] = 0.0542 * ds[bar] + 0.0210 * ds[bar - 1]
                                    + 0.0210 * ds[bar - 2] + 0.0542 * ds[bar - 3]
                                    + 1.9733 * Value1ht[bar - 1] - 1.6067 * Value1ht[bar - 2]
                                    + 0.4831 * Value1ht[bar - 3];

                    Value2ht[bar] = 0.8 * (Value1ht[bar]
                                           - 2.0 * Math.Cos(DegreeToRadian(360 / 10))
                                           * Value1ht[bar - 1] + Value1ht[bar - 2])
                                    + 1.6 * Math.Cos(DegreeToRadian(360 / 10))
                                    * Value2ht[bar - 1] - 0.6 * Value2ht[bar - 2];

                    Result[bar] = 0.9 * (Value2ht[bar]
                                         - 2.0 * Math.Cos(DegreeToRadian(360 / DC[bar]))
                                         * Value2ht[bar - 1] + Value2ht[bar - 2])
                                  + 1.8 * Math.Cos(DegreeToRadian(360 / DC[bar]))
                                  * Result[bar - 1] - 0.8 * Result[bar - 2];
                }
                else
                {
                    Result[bar] = Result[bar - 1];
                }

                base[bar] = Result[bar];
            }
        }