Beispiel #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];
            }
        }
Beispiel #2
0
        public static ConsecDaysUp Series(DataSeries ds, double pct)
        {
            string description = string.Concat(new object[] { "Consecutive Days Up(", ds.Description, ",", pct, ")" });

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

            ConsecDaysUp _ConsecDaysUp = new ConsecDaysUp(ds, pct, description);

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