Пример #1
0
 public OutlineItem(OutlineItem original, double newPrice)
 {
     Price       = newPrice;
     DateValue   = original.DateValue;
     Type        = original.Type;
     RecordIndex = original.RecordIndex;
 }
Пример #2
0
        //public Double DoubleRate { get { return Rate * 2; } }

        //public Double QuadrupleRate { get { return Rate * 4; } }

        //public Double OctupleRate { get { return Rate * 8; } }

        //public Double HalfRate { get { return Rate * 0.5; } }

        //public Double QuarterRate { get { return Rate * 0.25; } }

        //public Double OctantRate { get { return Rate * 0.125; } }

        #endregion

        #endregion

        #region Constructors

        public GannTrend(OutlineItem start, OutlineItem end, GannTrendWays way)
        {
            Rule = way;
            OutlineItem ori = null, des = null;
            double      rate = 0;

            switch (Rule)
            {
            case GannTrendWays.Original:
                getOriginal(start, end, out ori, out des, out rate);
                break;

            case GannTrendWays.CalendarNatural:
                getCalendarNatural(start, end, out ori, out des, out rate);
                break;

            case GannTrendWays.IndexNatural:
                getIndexNatural(start, end, out ori, out des, out rate);
                break;

            case GannTrendWays.OriginalNatural:
                getOriginalNaturalTrend(start, end, out ori, out des, out rate);
                break;

            default:
                break;
            }
            Original      = ori;
            Destinational = des;
            Rate          = rate;
        }
Пример #3
0
        private static void getOriginalNaturalTrend(OutlineItem start, OutlineItem end, out OutlineItem original, out OutlineItem destinational, out Double rate)
        {
            Double interval = (end.DateValue - start.DateValue);
            Double tempRate = (end.Price - start.Price) / interval;

            if (Math.Abs(tempRate) > 100 || Math.Abs(tempRate) < 0.0000001)
            {
                throw new Exception();
            }

            rate          = naturalRateOf(tempRate);
            original      = new OutlineItem(start, naturalValueOf(start.Price, tempRate));
            destinational = new OutlineItem(end, original.Price + rate * interval);
        }
Пример #4
0
        private static void getIndexNatural(OutlineItem start, OutlineItem end, out OutlineItem original, out OutlineItem destinational, out Double rate)
        {
            Double interval = (end.RecordIndex - start.RecordIndex);
            Double tempRate = (end.Price - start.Price) / interval;

            if (Math.Abs(tempRate) > 10000 || Math.Abs(tempRate) < 0.00001)
            {
                throw new Exception();
            }

            rate          = naturalRateOf(tempRate);
            original      = start;
            destinational = new OutlineItem(end, original.Price + rate * interval);
        }
Пример #5
0
 public static GannTrend GetOriginalNaturalTrend(OutlineItem start, OutlineItem end)
 {
     return(new GannTrend(start, end, GannTrendWays.OriginalNatural));
 }
Пример #6
0
 public static GannTrend GetIndexNaturalTrend(OutlineItem start, OutlineItem end)
 {
     return(new GannTrend(start, end, GannTrendWays.IndexNatural));
 }
Пример #7
0
 public static GannTrend GetCalendarNaturalTrend(OutlineItem start, OutlineItem end)
 {
     return(new GannTrend(start, end, GannTrendWays.CalendarNatural));
 }
Пример #8
0
 private static void getOriginal(OutlineItem start, OutlineItem end, out OutlineItem original, out OutlineItem destinational, out Double rate)
 {
     rate          = (end.Price - start.Price) / (end.DateValue - start.DateValue);
     original      = start;
     destinational = end;
 }