Пример #1
0
        public static CDLBELTHOLD Series(DataBars ds, string name)
        {
            //Build description
            string description = "(" + name + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((CDLBELTHOLD)obj);
            }

            //Create Doji, cache it, return it
            CDLBELTHOLD indicator = new CDLBELTHOLD(ds, description);

            ds.Cache.Add(description, indicator);
            return(indicator);
        }
Пример #2
0
        /// <summary>
        /// Static method to create AVGPRICE DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static AVGPRICE Series(DataBars ds, string name)
        {
            //Build description
            string description = "(" + name + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((AVGPRICE)obj);
            }

            //Create indicator, cache it, return it
            AVGPRICE indicator = new AVGPRICE(ds, description);

            ds.Cache.Add(description, indicator);
            return(indicator);
        }
Пример #3
0
        /// <summary>
        /// Static method to create SAR DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static SAR Series(DataBars ds, double optInAcceleration, double optLnMaximum, string name)
        {
            //Build description
            string description = "(" + name + "," + optInAcceleration.ToString() + "," + optLnMaximum.ToString() + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((SAR)obj);
            }

            //Create indicator, cache it, return it
            SAR indicator = new SAR(ds, optInAcceleration, optLnMaximum, description);

            ds.Cache.Add(description, indicator);
            return(indicator);
        }
Пример #4
0
        /// <summary>
        /// Static method to create Arron DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static CCI Series(DataBars ds, double period, string name)
        {
            //Build description
            string description = "(" + name + "," + period.ToString() + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((CCI)obj);
            }

            //Create CCI, cache it, return it
            CCI cci = new CCI(ds, period, description);

            ds.Cache.Add(description, cci);
            return(cci);
        }
Пример #5
0
        /// <summary>
        /// Static method to create AD DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static AD Series(DataBars ds, string name)
        {
            //Build description
            string description = "(" + name + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((AD)obj);
            }

            //Create AD, cache it, return it
            AD ad = new AD(ds, description);

            ds.Cache.Add(description, ad);
            return(ad);
        }
Пример #6
0
        /// <summary>
        /// Static method to create ATR DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ATR Series(DataBars ds, double period, string name)
        {
            //Build description
            string description = "(" + name + "," + period.ToString() + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((ATR)obj);
            }

            //Create indicator, cache it, return it
            ATR indicator = new ATR(ds, period, description);

            ds.Cache.Add(description, indicator);
            return(indicator);
        }
Пример #7
0
        public static CDLABANDONEDBABY Series(DataBars ds, double optInPenetration, string name)
        {
            //Build description
            string description = "(" + name + ")";
            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((CDLABANDONEDBABY)obj);
            }

            //Create Doji, cache it, return it
            CDLABANDONEDBABY indicator = new CDLABANDONEDBABY(ds, optInPenetration, description);

            ds.Cache.Add(description, indicator);
            return(indicator);
        }
Пример #8
0
        protected baseDX(DataBars ds, Types type, int period, string name) : base(ds, name)
        {
            int begin = 0, length = 0;

            Core.RetCode retCode = Core.RetCode.UnknownErr;
            double[]     output  = new double[ds.Count];
            switch (type)
            {
            case Types.ADX:
                retCode = Core.Dx(0, ds.Count - 1, ds.High.Values, ds.Low.Values, ds.Close.Values, period, out begin, out length, output);
                break;

            case Types.PlusDI:
                retCode = Core.PlusDI(0, ds.Count - 1, ds.High.Values, ds.Low.Values, ds.Close.Values, period, out begin, out length, output);
                break;

            case Types.MinusDI:
                retCode = Core.MinusDI(0, ds.Count - 1, ds.High.Values, ds.Low.Values, ds.Close.Values, period, out begin, out length, output);
                break;

            case Types.MinusDM:
                retCode = Core.MinusDM(0, ds.Count - 1, ds.High.Values, ds.Low.Values, period, out begin, out length, output);
                break;

            case Types.PlusDM:
                retCode = Core.PlusDM(0, ds.Count - 1, ds.High.Values, ds.Low.Values, period, out begin, out length, output);
                break;
            }
            if (retCode != Core.RetCode.Success)
            {
                return;
            }
            //Assign first bar that contains indicator data
            FirstValidValue = begin;
            this.Name       = name;
            for (int idx = 0; idx < begin; idx++)
            {
                this[idx] = 0;
            }
            for (int i = begin, j = 0; j < length; i++, j++)
            {
                this[i] = output[j];
            }
        }
Пример #9
0
        /// <summary>
        /// Static method to create ADOSC DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="fastPeriod"></param>
        /// <param name="slowPeriod"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ADOSC Series(DataBars ds, double fastPeriod, double slowPeriod, string name)
        {
            //Build description
            string description = "(" + name + "," + fastPeriod.ToString() + "," + slowPeriod.ToString() + ")";

            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((ADOSC)obj);
            }

            //Create ADOSC, cache it, return it
            ADOSC adosc = new ADOSC(ds, fastPeriod, slowPeriod, description);

            ds.Cache.Add(description, adosc);
            return(adosc);
        }
Пример #10
0
        /// <summary>
        /// Static method to create Arron DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Aroon Series(DataBars ds, double period, string name)
        {
            //Build description
            string description = "(" + name + "," + period.ToString() + ")";

            //See if it exists in the cache
            object obj = ds.Cache.Find(description);

            if (obj != null)
            {
                return((Aroon)obj);
            }

            //Create Aroon, cache it, return it
            Aroon aroon = new Aroon(ds, period, description);

            ds.Cache.Add(description, aroon);
            return(aroon);
        }
Пример #11
0
        /// <summary>
        /// Calculation of Chaikin A/D Oscillator indicators
        /// </summary>
        /// <param name="db">data to calculate AD</param>
        /// <param name="name"></param>
        public ADOSC(DataBars db, double fastPeriod, double slowPeriod, string name)
            : base(db, name)
        {
            int begin = 0, length = 0;

            Core.RetCode retCode = Core.RetCode.UnknownErr;

            double[] output = new double[db.Count];

            retCode = Core.AdOsc(0, db.Count - 1, db.High.Values, db.Low.Values, db.Close.Values, db.Volume.Values, (int)fastPeriod, (int)slowPeriod, out begin, out length, output);

            if (retCode != Core.RetCode.Success)
            {
                return;
            }
            //Assign first bar that contains indicator data
            FirstValidValue = begin;
            this.Name       = name;
            for (int i = begin, j = 0; j < length; i++, j++)
            {
                this[i] = output[j];
            }
        }
Пример #12
0
        /// <summary>
        /// Calculation of Aroon indicators
        /// </summary>
        /// <param name="db">data to calculate Aroon</param>
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public Aroon(DataBars db, double period, string name)
            : base(db, name)
        {
            int begin = 0, length = 0;

            Core.RetCode retCode = Core.RetCode.UnknownErr;

            double[] outputDown = new double[db.Count];
            double[] outputUp   = new double[db.Count];

            retCode = Core.Aroon(0, db.Count - 1, db.High.Values, db.Low.Values, (int)period, out begin, out length, outputDown, outputUp);

            if (retCode != Core.RetCode.Success)
            {
                return;
            }
            //Assign first bar that contains indicator data
            if (length <= 0)
            {
                FirstValidValue = begin + outputDown.Length + 1;
            }
            else
            {
                FirstValidValue = begin;
            }
            this.Name = name;
            DataSeries upValue = new DataSeries(db, name + "-aroon up");

            upValue.FirstValidValue = FirstValidValue;

            for (int i = begin, j = 0; j < length; i++, j++)
            {
                this[i]           = outputDown[j];
                upValue.Values[i] = outputUp[j];
            }
            this.Cache.Add(upValue.Name, upValue);
        }
Пример #13
0
        /// <summary>
        /// Calculation of Average True Range indicators
        /// </summary>
        /// <param name="ds">data to calculate HT_PHASOR</param>
        /// <param name="period">the period</param>
        /// <param name="name"></param>
        public HT_PHASOR(DataBars ds, string name)
            : base(ds, name)
        {
            int begin = 0, length = 0;

            Core.RetCode retCode = Core.RetCode.UnknownErr;

            double[] output     = new double[ds.Count];
            double[] quadrature = new double[ds.Count];

            retCode = Core.HtPhasor(0, ds.Count - 1, ds.High.Values, out begin, out length, output, quadrature);

            if (retCode != Core.RetCode.Success)
            {
                return;
            }
            //Assign first bar that contains indicator data
            DataSeries quadratureSeries = new DataSeries(ds, name + "-quadrature");

            if (length <= 0)
            {
                FirstValidValue = begin + output.Length + 1;
            }
            else
            {
                FirstValidValue = begin;
            }
            quadratureSeries.FirstValidValue = FirstValidValue;

            this.Name = name;
            for (int i = begin, j = 0; j < length; i++, j++)
            {
                quadratureSeries.Values[i] = quadrature[j];
                this[i] = output[j];
            }
            this.Cache.Add(quadratureSeries.Name, quadratureSeries);
        }
Пример #14
0
        public StochF(DataBars db, double fastK_Period, double fastD_Period, string name) : base(db, name)
        {
            this.Name = name;
            int begin = 0, length = 0;

            double[]     outFastK = new double[db.Count];
            double[]     outFastD = new double[db.Count];
            Core.RetCode retCode  = Core.StochF(0, db.Count - 1, db.High.Values, db.Low.Values, db.Close.Values, (int)fastK_Period, (int)fastD_Period, Core.MAType.Sma,
                                                out begin, out length, outFastK, outFastD);

            if (retCode != Core.RetCode.Success)
            {
                return;
            }

            if (length <= 0)
            {
                FirstValidValue = begin + outFastK.Length + 1;
            }
            else
            {
                FirstValidValue = begin;
            }
            this.Name = name;

            DataSeries fastDSeries = new DataSeries(db, name + "-fastD");

            fastDSeries.FirstValidValue = FirstValidValue;
            for (int i = begin, j = 0; j < length; i++, j++)
            {
                this[i] = outFastK[j];
                fastDSeries.Values[i] = outFastD[j];
            }
            //Cache series
            this.Cache.Add(fastDSeries.Name, fastDSeries);
            return;
        }
Пример #15
0
 public MinusDM(DataBars ds, int period, string name) : base(ds, Types.MinusDM, period, name)
 {
 }
Пример #16
0
 public PlusDI(DataBars ds, int period, string name) : base(ds, Types.PlusDI, period, name)
 {
 }
Пример #17
0
 public ADX(DataBars ds, int period, string name) : base(ds, Types.ADX, period, name)
 {
 }
Пример #18
0
 public PlusDM(DataBars ds, double period, string name) : base(ds, Types.PlusDM, period, name)
 {
 }
Пример #19
0
 public SARATRRules(DataBars db, double atrperiod, double optInAcc, double optLnMax)
 {
     rules    = new Rule[2];
     rules[0] = new BasicSARRule(db, optInAcc, optLnMax);
     rules[1] = new BasicATRRule(db, atrperiod, "atr");
 }
        public void AddDataBar(DataBar dataBar)
        {
            DataBars.Add(dataBar);

            SetDataBarWidths();
        }
Пример #21
0
 public StockFastRule(DataBars db, Parameters parameters)
 {
     stoch = Indicators.StochF.Series(db, parameters[0], parameters[1], "");
     line1 = stoch.FastKSeries;
     line2 = stoch.FastDSeries;
 }
Пример #22
0
 public MACDHistATRRules(DataBars db, double atrperiod, double fast, double slow, double signal)
 {
     rules    = new Rule[2];
     rules[0] = new MACD_HistogramRule(db.Close, fast, slow, signal);
     rules[1] = new BasicATRRule(db, atrperiod, "atr");
 }
Пример #23
0
 public static baseDX Series(DataBars ds, int period, string name)
 {
     return(CreateSeries(ds, Types.MinusDM, period, name));
 }
Пример #24
0
 public MinusDM(DataBars ds, int period, string name) : base(ds, Types.MinusDM, period, name) { }
Пример #25
0
 public PlusDI(DataBars ds, int period, string name) : base(ds, Types.PlusDI, period, name) { }
Пример #26
0
 public ADX(DataBars ds, int period, string name) : base(ds, Types.ADX, period, name) { }
Пример #27
0
 protected baseDX(DataBars ds, Types type, int period, string name) : base(ds, name)
 {
     int begin = 0, length = 0;
     Core.RetCode retCode = Core.RetCode.UnknownErr;
     double[] output = new double[ds.Count];
     switch (type)
     {
         case Types.ADX:
              retCode = Core.Dx(0, ds.Count - 1, ds.High.Values, ds.Low.Values, ds.Close.Values, period, out begin, out length, output); 
              break;
         case Types.PlusDI :
              retCode = Core.PlusDI(0, ds.Count - 1, ds.High.Values, ds.Low.Values, ds.Close.Values, period, out begin, out length, output); 
              break;
         case Types.MinusDI:
              retCode = Core.MinusDI(0, ds.Count - 1, ds.High.Values, ds.Low.Values, ds.Close.Values, period, out begin, out length, output); 
              break;
         case Types.MinusDM:
              retCode = Core.MinusDM(0, ds.Count - 1, ds.High.Values, ds.Low.Values,period, out begin, out length, output);
              break;
         case Types.PlusDM:
              retCode = Core.PlusDM(0, ds.Count - 1, ds.High.Values, ds.Low.Values, period, out begin, out length, output);
              break;
     }
     if (retCode != Core.RetCode.Success) return;
     //Assign first bar that contains indicator data
     FirstValidValue = begin;
     this.Name = name;
     for (int idx = 0; idx < begin; idx++) this[idx] = 0;
     for (int i = begin, j = 0; j < length; i++, j++) this[i] = output[j];
 }
Пример #28
0
 protected static baseDX CreateSeries(DataBars ds, Types type, int period, string name)
 {
     //Build description
     string description = "(" + name + "," + period + ")";
     //See if it exists in the cache
     if (ds.Cache.ContainsKey(description))
         return (baseDX)ds.Cache[description];
     //Create DI, cache it, return it
     baseDX di = new baseDX(ds, type, period, description);
     ds.Cache[description] = di;
     return di;
 }
Пример #29
0
 public BasicAroonRule(DataBars db, double period)
 {
     aroon = new Indicators.Aroon(db, period, "aroon");
 }
Пример #30
0
 public BasicATRRule(DataBars db, double period, string name)
 {
     atr  = Indicators.ATR.Series(db, period, name);
     data = db;
 }
Пример #31
0
 public StockFastRule(DataBars db, double _fastK, double _fastD, string _name)
 {
     stoch = Indicators.StochF.Series(db, _fastK, _fastD, _name);
     fastK = stoch.FastKSeries;
     fastD = stoch.FastDSeries;
 }
Пример #32
0
 public BollingerKeltnerEMARule(DataBars db, double BolligerPeriod, double kUp, double kDn, double EmaPeriod, double AtrMult, double AtrPeriod, double emaShortPeriod, double emaLongPeriod)
 {
     bolliger = Indicators.BBANDS.Series(db.Close, BolligerPeriod, kUp, kDn, "bolliger");
     keltner  = Indicators.KELTNER.Series(db, EmaPeriod, AtrMult, AtrPeriod, "keltner");
     emaRule  = new TwoEMARule(db.Close, emaShortPeriod, emaLongPeriod);
 }
Пример #33
0
 public BasicSARRule(DataBars db, double optInAcc, double optLnMax)
 {
     sar   = new Indicators.SAR(db, optInAcc, optLnMax, "sar");
     close = db.Close;
 }
Пример #34
0
 public static baseDX Series(DataBars ds, double period, string name)
 {
     return(Series(ds, Types.MinusDM, period, name));
 }
Пример #35
0
 public static baseDX Series(DataBars ds, int period, string name)
 {
     return CreateSeries(ds, Types.MinusDM, period, name);
 }
Пример #36
0
 public StochSlowRule(DataBars db, double fastK, double slowK, double slowD)
 {
     stoch = Indicators.Stoch.Series(db, fastK, slowK, slowD, "stoch");
     line1 = stoch.SlowKSeries;
     line2 = stoch.SlowDSeries;
 }