예제 #1
0
        public ConnorsRSI(DataSeries ds, int periodRSI, int periodStreak, int periodPR, string description)
            : base(ds, description)
        {
            base.FirstValidValue = Math.Max(Math.Max(periodRSI, periodStreak), periodPR);
            if (FirstValidValue <= 1)
            {
                return;
            }

            ConsecDaysDown cdd    = ConsecDaysDown.Series(ds, 0);
            ConsecDaysUp   cdu    = ConsecDaysUp.Series(ds, 0);
            DataSeries     streak = new DataSeries(ds, "streak");

            for (int bar = 0; bar < ds.Count; bar++)
            {
                streak[bar] = cdd[bar] > 0 ? -cdd[bar] : cdu[bar] > 0 ? cdu[bar] : 0;
            }

            RSI        rsi3       = RSI.Series(ds, periodRSI);
            RSI        rsiStreak  = RSI.Series(streak, periodStreak);
            ROC        ret        = ROC.Series(ds, 1);
            DataSeries pr         = PercentRank.Series(ret, periodPR) * 100.0;
            DataSeries connorsRSI = (rsi3 + rsiStreak + pr) / 3;

            for (int bar = base.FirstValidValue; bar < ds.Count; bar++)
            {
                base[bar] = connorsRSI[bar];
            }
        }
예제 #2
0
        public static ConsecDaysDown Series(DataSeries ds, double pct)
        {
            string description = string.Concat(new object[] { "Consecutive Days Down(", ds.Description, ",", pct, ")" });

            if (ds.Cache.ContainsKey(description))
            {
                return((ConsecDaysDown)ds.Cache[description]);
            }

            ConsecDaysDown _ConsecDaysDown = new ConsecDaysDown(ds, pct, description);

            ds.Cache[description] = _ConsecDaysDown;
            return(_ConsecDaysDown);
        }