コード例 #1
0
ファイル: DVCFE.cs プロジェクト: ToniTsai/LeetCode
        public DVCFE(Bars bars, int period1, int period2, int rankPeriod, string description)
            : base(bars, description)
        {
            if (FirstValidValue > bars.Count || FirstValidValue < 0)
            {
                FirstValidValue = bars.Count;
            }
            if (bars.Count < Math.Max(rankPeriod, Math.Max(period1, period2)))
            {
                return;
            }

            //Step 1
            DataSeries PriceChange = DataSeries.Abs(ROC.Series(bars.Close, 1));
            //Step 2
            DataSeries TenDayPriceChange = bars.Close - (bars.Close >> period1);
            DataSeries FirstRatio        = (TenDayPriceChange / Sum.Series(PriceChange, period1)) * -1;
            //Step 3
            DataSeries TwoFiftyDayPriceChange = bars.Close - (bars.Close >> period2);
            DataSeries SecondRatio            = (TwoFiftyDayPriceChange / Sum.Series(PriceChange, period2));
            //Step 4
            DataSeries Average = (FirstRatio + SecondRatio) / 2;
            DataSeries DVCFE   = PrcRank.Series(Average, rankPeriod);

            base.FirstValidValue = Math.Max(Math.Max(period1, period2), rankPeriod);
            if (FirstValidValue == 1)
            {
                return;
            }

            for (int bar = base.FirstValidValue; bar < bars.Count; bar++)
            {
                base[bar] = DVCFE[bar];
            }
        }
コード例 #2
0
        public PsychologicalIndex(Bars bars, int period, string description)
            : base(bars, description)
        {
            base.FirstValidValue = period;

            DataSeries UpDay = Momentum.Series(bars.Close, 1);

            UpDay = ((UpDay / DataSeries.Abs(UpDay)) + 1) / 2;

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                base[bar] = (WealthLab.Indicators.Sum.Series(UpDay, period)[bar] / period) * 100;
            }
        }
コード例 #3
0
ファイル: TrendScore.cs プロジェクト: ToniTsai/LeetCode
        public TrendScore(Bars bars, string description)
            : base(bars, description)
        {
            base.FirstValidValue = 20;

            DataSeries ScoreSeries = new DataSeries(bars, "TrendScore");

            for (int j = 11; j <= 20; j++)
            {
                Momentum   Mj = Momentum.Series(bars.Close, j);
                DataSeries Sj = Mj / DataSeries.Abs(Mj);
                ScoreSeries += Sj;
            }

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                base[bar] = ScoreSeries[bar];
            }
        }
コード例 #4
0
ファイル: SeriesAboveBelow.cs プロジェクト: ToniTsai/LeetCode
        public SeriesIsBelowValue(DataSeries ds, double num, int period, string description)
            : base(ds, description)
        {
            int        lp    = ds.Count;
            DataSeries delta = (double)num - ds;

            delta += DataSeries.Abs(delta);
            delta /= delta;
            DataSeries aux = Sum.Series(delta, period) + 1.0e-9;  // keep in mind we're working with floating point numbers

            if (period > lp)
            {
                return;
            }

            for (int bar = period; bar < lp; bar++)
            {
                base[bar] = aux[bar];
            }
        }
コード例 #5
0
        public TSI(DataSeries ds, int period1, int period2, string description)
            : base(ds, description)
        {
            base.FirstValidValue = Math.Max(period1, period2) * 3;
            if (FirstValidValue <= 1)
            {
                return;
            }

            DataSeries mtm    = Momentum.Series(ds, 1);
            DataSeries absmtm = DataSeries.Abs(mtm);
            DataSeries Numer  = EMA.Series(EMA.Series(mtm, period1, EMACalculation.Modern), period2, EMACalculation.Modern);
            DataSeries Denom  = EMA.Series(EMA.Series(absmtm, period1, EMACalculation.Modern), period2, EMACalculation.Modern);
            DataSeries TS     = Numer / Denom;
            DataSeries TSI    = TS * 100;

            for (int bar = base.FirstValidValue; bar < ds.Count; bar++)
            {
                base[bar] = TSI[bar];
            }
        }
コード例 #6
0
        public UDIDSRI(DataSeries ds, int period, int power, int percentRankPeriod, int iteration, string description)
            : base(ds, description)
        {
            base.FirstValidValue = Math.Max(period, percentRankPeriod);

            DataSeries diff     = ds - (ds >> 1);
            DataSeries mov      = new DataSeries(ds, "mov(" + ds.Description + "," + period + "," + percentRankPeriod + ")");
            DataSeries movement = new DataSeries(ds, "movement(" + ds.Description + "," + period + "," + percentRankPeriod + ")");
            DataSeries r        = DataSeries.Abs(ds / (ds >> 1) - 1);

            int u_iteration = iteration == 1 ? 1 : 2;

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                if (diff[bar] > 0)
                {
                    mov[bar] = 1;
                }

                if (diff[bar] < 0)
                {
                    mov[bar] = -1;
                }

                movement[bar] = mov[bar] * Math.Pow((1 + r[bar]), power);
            }

            DataSeries UDIDSRI_1st = Sum.Series(mov, period);

            UDIDSRI_1st = PercentRank.Series(UDIDSRI_1st, percentRankPeriod);

            DataSeries UDIDSRI_2nd = Sum.Series(movement, period);

            UDIDSRI_2nd = PercentRank.Series(UDIDSRI_2nd, percentRankPeriod);

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                base[bar] = u_iteration == 1 ? UDIDSRI_1st[bar] : UDIDSRI_2nd[bar];
            }
        }
コード例 #7
0
        public HasslerTSI(Bars bars, DataSeries ds, int period1, int period2, string description)
            : base(ds, description)
        {
            base.FirstValidValue = Math.Max(period2, period1);

            if (FirstValidValue > ds.Count || FirstValidValue < 0)
            {
                FirstValidValue = ds.Count;
            }
            if (ds.Count < period1 || ds.Count < period2)
            {
                return;
            }

            ATR        atr        = ATR.Series(bars, period1);
            DataSeries Ratio      = DataSeries.Abs(ds - (ds >> period1)) / atr;
            DataSeries HasslerTSI = Community.Indicators.FastSMA.Series(Community.Indicators.FastSMA.Series(Ratio, period1), period2);

            for (int i = FirstValidValue; i < ds.Count; i++)
            {
                base[i] = HasslerTSI[i];
            }
        }