Exemple #1
0
        public static double PredictPrice(int period, double targetRSI, List <double> prices)
        {
            double currentPrice = prices.Last();
            double currentRSI   = RSICalculator.CalculateLastRsi(period, prices.ToArray());

            if (currentRSI == 0)
            {
                return(0);
            }
            if (targetRSI == currentRSI)
            {
                return(currentPrice);
            }

            double          targetRS = GetRS(targetRSI);
            AvgGainLossPair aglp     = GetAGL(period, prices.Count() - 1, prices);
            double          delta    = (targetRSI > currentRSI) ? targetRS * aglp.AvgLoss * 13 - aglp.AvgGain * 13 :
                                       (aglp.AvgGain * 13 / targetRS - aglp.AvgLoss * 13) * -1;

            return(currentPrice + delta);
        }
Exemple #2
0
        public static RSIRangeData GetRSIRange(int period, List <double> prices)
        {
            List <double> sortedRSI = RSICalculator.CalculateRsi(period, prices.ToArray()).OrderBy(e => e).ToList();
            int           count     = sortedRSI.Count();

            if (count < 100)
            {
                return(null);
            }

            RSIRangeData value = new RSIRangeData();

            value.Min = sortedRSI.First();
            value.Max = sortedRSI.Last();
            value.L5  = sortedRSI.Skip(count / 20).First();
            value.L10 = sortedRSI.Skip(count / 10).First();
            value.L15 = sortedRSI.Skip(count / 20 * 3).First();
            value.H5  = sortedRSI.Skip(count / 20 * 19).First();
            value.H10 = sortedRSI.Skip(count / 10 * 9).First();
            value.H15 = sortedRSI.Skip(count / 20 * 17).First();
            return(value);
        }