Ejemplo n.º 1
0
 public BasicDMIRule(DataBars db,double minusperiod,double plusperiod)
 {
     minusDmi = new Indicators.MinusDI(db, minusperiod, "minusDmi");
     plusDmi = new Indicators.PlusDI(db, plusperiod, "plusDmi");
     adx = new Indicators.ADX(db, minusperiod, "adx");
     emaadx = Indicators.EMA.Series(adx, 5, "emaadx");
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 protected baseSMA(DataSeries ds, Types type, double 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.SMA:
             retCode = Core.Sma(0, ds.Count - 1, ds.Values,(int)period, out begin, out length, output); break;
         case Types.EMA:
             retCode = Core.Ema(0, ds.Count - 1, ds.Values, (int)period, out begin, out length, output); break;
         case Types.WMA:
             retCode = Core.Wma(0, ds.Count - 1, ds.Values, (int)period, out begin, out length, output); break;
         case Types.RSI:
             retCode = Core.Rsi(0, ds.Count - 1, ds.Values, (int)period, out begin, out length, output); break;
     }
     if (retCode != Core.RetCode.Success) return;
     //Assign first bar that contains indicator data
     if (length <= 0)
         FirstValidValue = begin + output.Length + 1;
     else
         FirstValidValue = begin;
     this.Name = name;
     for (int i = begin, j = 0; j < length; i++, j++) this[i] = output[j];
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Calculation of HTSINE indicators
        /// </summary>
        /// <param name="ds">data to calculate HTSINE</param>        
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public HTSINE(DataSeries ds, string name)
            : base(ds, name)
        {
            int begin = 0, length = 0;
            Core.RetCode retCode = Core.RetCode.UnknownErr;

            double[] outsine = new double[ds.Count];
            double[] outleadsine = new double[ds.Count];


            retCode = Core.HtSine(0, ds.Count - 1, ds.Values, out begin, out length, outsine,outleadsine);
            
            if (retCode != Core.RetCode.Success) return;
            DataSeries leadSineSeries = new DataSeries(ds, name + "-leadSine");

            //Assign first bar that contains indicator data
            if (length <= 0)
                FirstValidValue = begin + outsine.Length + 1;
            else
                FirstValidValue = begin;

            this.Name = name;
            leadSineSeries.FirstValidValue = FirstValidValue;

            for (int i = begin, j = 0; j < length; i++, j++)
            {
                this[i] = outsine[j];
                leadSineSeries[i] = outleadsine[j];
            }
            //Cache Series
            this.Cache.Add(leadSineSeries.Name, leadSineSeries);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Calculation of MINMAX indicators
        /// </summary>
        /// <param name="db">data to calculate MINMAX</param>        
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public MINMAX(DataSeries db, double period, string name)
            : base(db, name)
        {
            int begin = 0, length = 0;
            Core.RetCode retCode = Core.RetCode.UnknownErr;

            double[] outmin = new double[db.Count];
            double[] outmax = new double[db.Count];


            retCode = Core.MinMax(0, db.Count - 1, db.Values, (int)period, out begin, out length, outmin, outmax);
            
            if (retCode != Core.RetCode.Success) return;
            //Assign first bar that contains indicator data
            if (length <= 0)
                FirstValidValue = begin + outmin.Length + 1;
            else
                FirstValidValue = begin;
            this.Name = name;
            DataSeries maxSeries = new DataSeries(db,name + "-max");
            maxSeries.FirstValidValue = FirstValidValue;

            for (int i = begin, j = 0; j < length; i++, j++)
            {
                this[i] = outmin[j];
                maxSeries[i] = outmax[j];
            }
            this.Cache.Add(maxSeries.Name, maxSeries);
        }
Ejemplo n.º 6
0
        private static commonClass.DataSeries MakeData(databases.tmpDS.marketDataDataTable dataTbl, DataFields type)
        {
            commonClass.DataSeries ds = new commonClass.DataSeries();
            switch (type)
            {
            case DataFields.Count:
                for (int idx = 0; idx < dataTbl.Count; idx++)
                {
                    ds.Add(dataTbl[idx].val0);
                }
                break;

            case DataFields.Volume:
                for (int idx = 0; idx < dataTbl.Count; idx++)
                {
                    ds.Add(dataTbl[idx].val1);
                }
                break;

            case DataFields.DateTime:
                for (int idx = 0; idx < dataTbl.Count; idx++)
                {
                    ds.Add(dataTbl[idx].onDate.ToOADate());
                }
                break;
            }
            return(ds);
        }
Ejemplo n.º 7
0
        /* Get average of a list for 0 to position
         */
        public static double findAverage(DataSeries list, int position, int number_Periods)
        {
            if (list.Count == 0 || position - number_Periods < 0) return 0;

            double average = 0;
            for (int i = position; i > position - number_Periods; i--)
                average += list[i];
            return average / number_Periods;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Detect if there is "days" cummulative down in close price
 /// </summary>
 /// <param name="closePrice"></param>
 /// <param name="idx"></param>
 /// <param name="days"></param>
 /// <returns></returns>
 static public bool isCummulativeDown(DataSeries closePrice, int idx, int days)
 {
     for (int i = idx; i > idx - days; i--)
     {
         if (closePrice[i] > closePrice[i - 1])
             return false;
     }
     return true;
 }
Ejemplo n.º 9
0
        /* Find the maximum value of a list, from position back to number_Periods period
         */
        public static double findResistance(DataSeries list, int position, int number_Periods)
        {
            if (list.Count == 0 || position - number_Periods < 0) return -1;

            double max = double.MinValue;
            for (int i = position; i > position - number_Periods; i--)
                if (max < list[i])
                    max = list[i];

            return max;
        }
Ejemplo n.º 10
0
        /* Find the minimum value of a list, from position back to number_Periods period
         */
        public static double findSupport(DataSeries list, int position, int number_Periods)
        {
            if (list.Count == 0 || position - number_Periods < 0) return -1;

            double min = double.MaxValue;
            for (int i = position; i > position - number_Periods; i--)
                if (min > list[i])
                    min = list[i];    
                
            return min;
        }
Ejemplo n.º 11
0
        private void DrawCurveIndicator(application.Indicators.Meta meta)
        {
            pricePane.myGraphObj.myGraphPane.CurveList.Clear();

            //Indicators.Meta meta = Indicators.Libs.FindMetaByName(indicatorName);
            string curveName = meta.ClassType.Name + "-" + meta.ParameterString;

            Charts.Controls.baseGraphPanel myGraphPanel = pricePane;

            commonClass.DataSeries indicatorSeries = application.Indicators.Libs.GetIndicatorData(this.myData, meta);
            this.myData.DateTime.FirstValidValue = indicatorSeries.FirstValidValue;
            switch (meta.Output[0].ChartType)
            {
            case commonClass.AppTypes.ChartTypes.Bar:
                PlotCurveBar(curveName, myGraphPanel, this.myData.DateTime, indicatorSeries,
                             meta.Output[0].Color, Color.Black, meta.Output[0].Weight);
                break;

            case commonClass.AppTypes.ChartTypes.Line:
                PlotCurveLine(curveName, myGraphPanel, this.myData.DateTime, indicatorSeries,
                              meta.Output[0].Color, meta.Output[0].Weight);
                break;
            }
            // Some indicator such as MACD having more than one output series.
            // In such case, indicator form MUST have [form.ExtraInfo] propery to provide information for the output series.
            commonClass.DataSeries[] extraSeries = null;
            if (meta.Output.Length > 1)
            {
                extraSeries = application.Indicators.Libs.GetIndicatorData(indicatorSeries, meta);
            }
            if (extraSeries != null)
            {
                for (int idx = 0, metaIdx = 1; idx < extraSeries.Length && metaIdx < meta.Output.Length; idx++, metaIdx++)
                {
                    this.myData.DateTime.FirstValidValue = extraSeries[idx].FirstValidValue;
                    curveName = meta.ClassType.Name + "-" + meta.ParameterString + "-" + idx.ToString();
                    switch (meta.Output[metaIdx].ChartType)
                    {
                    case commonClass.AppTypes.ChartTypes.Bar:
                        PlotCurveBar(curveName, myGraphPanel, this.myData.DateTime, extraSeries[idx],
                                     meta.Output[metaIdx].Color, Color.Black, meta.Output[metaIdx].Weight);
                        break;

                    case commonClass.AppTypes.ChartTypes.Line:
                        PlotCurveLine(curveName, myGraphPanel, this.myData.DateTime, extraSeries[idx],
                                      meta.Output[metaIdx].Color, meta.Output[metaIdx].Weight);
                        break;
                    }
                }
            }
            pricePane.myGraphObj.DefaultViewport();
            pricePane.myGraphObj.UpdateChart();
        }
Ejemplo n.º 12
0
        public static SRChannel Series(DataSeries 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 (SRChannel)obj;

            SRChannel indicator = new SRChannel(ds, period, description);
            ds.Cache.Add(description, indicator);
            return indicator;
        }
Ejemplo n.º 13
0
 protected static baseSMA Series(DataSeries ds, Types type, double period, string name)
 {
     //Build description
     string description = "(" + name + "," + period + ")";
     //See if it exists in the cache
     object obj = ds.Cache.Find(description);
     if (obj!=null) return (baseSMA)obj;
     //Create SMA, cache it, return it
     baseSMA sma = new baseSMA(ds, type, period, description);
     ds.Cache.Add(description,sma);
     return sma;
 }
Ejemplo n.º 14
0
 public static MACD Series(DataSeries ds, double fastPeriod, double slowPeriod, double signalPeriod, string name)
 {
     //Build description
     string description = "(" + name + "," + fastPeriod.ToString() + "," + slowPeriod.ToString() +","+signalPeriod.ToString()+ ")";
     //See if it exists in the cache
     object obj = ds.Cache.Find(description);
     if (obj!=null) return (MACD)obj;
     
     //Create MACD, cache it, return it
     MACD macd = new MACD(ds, fastPeriod, slowPeriod, signalPeriod, description);
     ds.Cache.Add(description,macd);
     return macd;
 }
Ejemplo n.º 15
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 ROCR100 Series(DataSeries 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 (ROCR100)obj;

            //Create indicator, cache it, return it
            ROCR100 indicator = new ROCR100(ds, period, description);
            ds.Cache.Add(description, indicator);
            return indicator;  
        }
Ejemplo n.º 16
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 STDDEV Series(DataSeries ds, double period,double optInNbDev, 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 (STDDEV)obj;

            //Create indicator, cache it, return it
            STDDEV indicator = new STDDEV(ds, period, optInNbDev, description);
            ds.Cache.Add(description, indicator);
            return indicator;
        }
Ejemplo n.º 17
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 HT_TRENDLINE Series(DataSeries 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 (HT_TRENDLINE)obj;

            //Create indicator, cache it, return it
            HT_TRENDLINE indicator = new HT_TRENDLINE(ds, description);
            ds.Cache.Add(description, indicator);
            return indicator;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Static method to create Thrust DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Market_TRIN Series(DataSeries 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 (Market_TRIN)obj;

            //Create indicator, cache it, return it
            Market_TRIN indicator = new Market_TRIN(ds, description);
            ds.Cache.Add(description, indicator);
            return indicator;
        }
Ejemplo n.º 19
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 RiskReward Series(DataSeries 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 (RiskReward)obj;

            //Create Aroon, cache it, return it
            RiskReward riskreward = new RiskReward(ds, period, description);
            ds.Cache.Add(description, riskreward);
            return riskreward;
        }
Ejemplo n.º 20
0
 private static commonClass.DataSeries MakeData(databases.tmpDS.marketDataDataTable dataTbl, DataFields type)
 {
     commonClass.DataSeries ds = new commonClass.DataSeries();
     switch (type)
     {
         case DataFields.Count:
             for (int idx = 0; idx < dataTbl.Count; idx++) ds.Add(dataTbl[idx].val0); break;
         case DataFields.Volume:
             for (int idx = 0; idx < dataTbl.Count; idx++) ds.Add(dataTbl[idx].val1); break;
         case DataFields.DateTime:
             for (int idx = 0; idx < dataTbl.Count; idx++) ds.Add(dataTbl[idx].onDate.ToOADate()); break;
     }
     return ds;
 }
Ejemplo n.º 21
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 LINEARREG_INTERCEPT Series(DataSeries 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 (LINEARREG_INTERCEPT)obj;

            //Create indicator, cache it, return it
            LINEARREG_INTERCEPT indicator = new LINEARREG_INTERCEPT(ds, period, description);
            ds.Cache.Add(description, indicator);
            return indicator;              
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Static method to create APO DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static APO Series(DataSeries ds, double fastperiod, double slowperiod, double matype, string name)
        {
            //Build description
            string description = "(" + name + fastperiod.ToString()+","+slowperiod.ToString()+","+matype.ToString() + ")";

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

            //Create indicator, cache it, return it
            APO indicator = new APO(ds, fastperiod,slowperiod,matype,description);
            ds.Cache.Add(description, indicator);
            return indicator;              
        }
Ejemplo n.º 23
0
        public Fibonnanci(DataBars ds, double period, string name)
            : base(ds, name)
        {
            this.Name = name;

            //138.2%, 161.8%, 200% and 261.8%

            DataSeries min = Indicators.MIN.Series(ds.Low, period, "min");
            DataSeries fibo100 = Indicators.MAX.Series(ds.High, period, "max");
            DataSeries fibo23pc = new DataSeries(min, "fibo 23pc");
            DataSeries fibo38pc = new DataSeries(min, "fibo 38pc");
            DataSeries fibo50pc = new DataSeries(min, "fibo 50pc");
            DataSeries fibo62pc = new DataSeries(min, "fibo 62pc");
            DataSeries fibo138pc = new DataSeries(min, "fibo 138pc");

            fibo23pc.Name = name + "-fibo 23pc";
            fibo38pc.Name = name + "-fibo 38pc";
            fibo50pc.Name = name + "-fibo 50pc";
            fibo62pc.Name = name + "-fibo 62pc";
            fibo138pc.Name = name + "-fibo 138pc";

            fibo100.Name = name + "-fibo100";

            FirstValidValue = (int)Math.Max(0,min.Count-period-1);;
            fibo100.FirstValidValue=FirstValidValue;
            fibo23pc.FirstValidValue = FirstValidValue;
            fibo38pc.FirstValidValue=FirstValidValue;
            fibo50pc.FirstValidValue = FirstValidValue;
            fibo62pc.FirstValidValue = FirstValidValue;
            fibo138pc.FirstValidValue = FirstValidValue;

            this.Name = name;

            for (int i = FirstValidValue; i < min.Count; i++)
            {
                this[i] = min[min.Count - 1];
                fibo100[i] = fibo100[fibo100.Count - 1];
                fibo23pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 23.6 / 100;
                fibo38pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1])*38.2/100;
                fibo50pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 50 / 100;
                fibo62pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 61.8 / 100;
                fibo138pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 138.2 / 100;
            }
            this.Cache.Add(fibo100.Name, fibo100);
            this.Cache.Add(fibo23pc.Name, fibo38pc);
            this.Cache.Add(fibo38pc.Name, fibo38pc);
            this.Cache.Add(fibo50pc.Name, fibo50pc);
            this.Cache.Add(fibo62pc.Name, fibo62pc);
            this.Cache.Add(fibo138pc.Name, fibo138pc);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Calculation of APO indicators
        /// </summary>
        /// <param name="db">data to calculate MFI</param>        
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public APO(DataSeries db, double fastperiod, double slowperiod, double matype, string name)
            : base(db, name)
        {
            int begin = 0, length = 0;
            Core.RetCode retCode = Core.RetCode.UnknownErr;

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

            switch ((int)matype)
            {
                case 0:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Dema, out begin, out length, output);
                    break;
                case 1:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Ema, out begin, out length, output);
                    break;
                case 2:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Kama, out begin, out length, output);
                    break;
                case 3:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Mama, out begin, out length, output);
                    break;
                case 4:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Sma, out begin, out length, output);
                    break;
                case 5:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.T3, out begin, out length, output);
                    break;
                case 6:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Tema, out begin, out length, output);
                    break;
                case 7:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Trima, out begin, out length, output);
                    break;
                case 8:
                    retCode = Core.Apo(0, db.Count - 1, db.Values, (int)fastperiod, (int)slowperiod, Core.MAType.Wma, out begin, out length, output);
                    break;
            }
            if (retCode != Core.RetCode.Success) return;
            //Assign first bar that contains indicator data
            if (length <= 0)
                FirstValidValue = begin + output.Length + 1;
            else
                FirstValidValue = begin;
            this.Name = name;

            for (int i = begin, j = 0; j < length; i++, j++)
                this[i] = output[j];
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Static method to create CORREL DataSeries
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="period"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static CORREL Series(DataSeries ds, DataSeries ds1, 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 (CORREL)obj;

            //application.Data stockData = new application.Data(AppTypes.TimeRanges.Y1, AppTypes.TimeScaleFromCode("D1"), stockname);
            //DataSeries ds1 = new DataSeries(stockData.Bars, stockname);
            //Create indicator, cache it, return it
            CORREL indicator = new CORREL(ds,ds1, period, description);
            ds.Cache.Add(description, indicator);
            return indicator;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Calculation of Correlation indicators
        /// </summary>
        /// <param name="db">data to calculate CORREL</param>
        /// <param name="period">the period</param>
        /// <param name="name"></param>
        public CORREL(DataSeries db,DataSeries db1, double period, string name)
            : base(db, name)
        {
            int begin = 0, length = 0;
            Core.RetCode retCode = Core.RetCode.UnknownErr;

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

            retCode = Core.Correl(0, db.Count - 1,db.Values ,db1.Values, (int)period, out begin, out length, output);

            if (retCode != Core.RetCode.Success) return;
            //Assign first bar that contains indicator data
            if (length <= 0)
                FirstValidValue = begin + output.Length + 1;
            else
                FirstValidValue = begin;
            this.Name = name;
            for (int i = begin, j = 0; j < length; i++, j++) this[i] = output[j];
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Calculation of RiskReward indicators
        /// </summary>
        /// <param name="db">data to calculate Aroon</param>        
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public RiskReward(DataSeries ds, double period, string name)
            : base(ds, name)
        {
            int begin = 0;

            Indicators.MIN min = Indicators.MIN.Series(ds, period, "min");
            Indicators.MAX max = Indicators.MAX.Series(ds, period, "max");
            DataSeries distance1 = ds - min;
            DataSeries distance2 = max - ds;
            DataSeries riskreward = distance2 / distance1;
            
            FirstValidValue = max.FirstValidValue;
            this.Name = name;

            for (int i = begin, j = 0; j < riskreward.Count; i++, j++)
            {
                this[i] = riskreward[j];
            }
        }
Ejemplo n.º 28
0
        public SRChannel(DataSeries ds, double period, string name)
            : base(ds, name)
        {
            this.Name = name;
            int begin = 0, length = 0;

            DataSeries min = Indicators.MIN.Series(ds, period, "min");
            DataSeries max = Indicators.MAX.Series(ds, period, "max");

            max.Name = name + "-resistance";

            FirstValidValue = min.FirstValidValue;
            this.Name = name;

            for (int i = begin, j = 0; j < min.Count; i++, j++)
            {
                this[i] = min[j];
            }
            this.Cache.Add(max.Name, max);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Calculation of HTTRENDMODE indicators
        /// </summary>
        /// <param name="db">data to calculate HTTRENDMODE</param>        
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public HTTRENDMODE(DataSeries db, string name)
            : base(db, name)
        {
            int begin = 0, length = 0;
            Core.RetCode retCode = Core.RetCode.UnknownErr;

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

            retCode = Core.HtTrendMode(0, db.Count - 1, db.Values, out begin, out length, output);

            if (retCode != Core.RetCode.Success) return;
            //Assign first bar that contains indicator data
            if (length <= 0)
                FirstValidValue = begin + output.Length + 1;
            else
                FirstValidValue = begin;
            this.Name = name;

            for (int i = begin, j = 0; j < length; i++, j++)
                this[i] = output[j];
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Calculation of Thrust indicators
        /// </summary>
        /// <param name="ds">data to calculate CCI</param>        
        /// <param name="period">period to calculate</param>
        /// <param name="name"></param>
        public Market_TRIN(DataSeries ds, string name)
            : base(ds, name)
        {
            //application.Data stockData = new application.Data(AppTypes.TimeRanges.Y1, AppTypes.TimeScaleFromCode("D1"), "SSI");
            application.MarketData market = new application.MarketData(AppTypes.TimeRanges.Y1, AppTypes.TimeScaleFromCode("D1"));
            DataSeries advancingIssues = market.AdvancingIssues;
            DataSeries decliningIssues = market.DecliningIssues;

            DataSeries advancingVolume = market.AdvancingVolume;
            DataSeries decliningVolume = market.DecliningVolume;

            DataSeries result1 = advancingIssues / decliningIssues;
            DataSeries result2 = advancingVolume / decliningVolume;

            DataSeries result3 = result1 / result2;

            int begin = 0;
            FirstValidValue = 0;
            this.Name = name;
            for (int i = begin, j = 0; j < result3.Count; i++, j++)
                this[i] = result3[j];
        }
Ejemplo n.º 31
0
        private CurveItem PlotCurveLine(string curveName, Charts.Controls.baseGraphPanel graphPane, commonClass.DataSeries xSeries, commonClass.DataSeries ySeries,
                                        Color color, int weight)
        {
            pricePane.myGraphObj.SetSeriesX(xSeries.Values, Charts.AxisType.DateAsOrdinal);
            CurveItem curveItem = graphPane.myGraphObj.AddCurveLine(curveName, ySeries.Values, SymbolType.None, color, weight);

            return(curveItem);
        }
Ejemplo n.º 32
0
 public PriceTwoSMARule(DataSeries ds, double shortperiod, double longperiod)
 {
     price = ds;
     short_indicator = Indicators.SMA.Series(ds, shortperiod, "sma");
     long_indicator = Indicators.SMA.Series(ds, longperiod, "sma");
 }
Ejemplo n.º 33
0
 public MACD_HistogramRule(DataSeries ds, double fast, double slow, double signal)
 {
     macd = Indicators.MACD.Series(ds, fast, slow, signal, "macd");
     ema = macd.SignalSeries;
     hist = macd.HistSeries;
 }
Ejemplo n.º 34
0
 protected void Set(DataSeries d)
 {
     this._values         = d._values;
     this.FirstValidValue = d.FirstValidValue;
 }