Пример #1
0
        public double ValueWhen(int offset, Func <double, int, bool> callback, ReferenceSeries searchPattern)
        {
            var allNumericSeries = DataSeriesManager.getAllNumericSerries();

            var index = allNumericSeries.FindIndex(x => x.Name == searchPattern.Name);

            var result  = -1D;
            var counter = 0;

            if (index != -1)
            {
                for (int i = 0; i < HistoryDataSeries.Count - 1; i++)
                {
                    if (Convert.ToBoolean(callback(allNumericSeries[index].GetValueByIndex(i), i)))
                    {
                        result   = searchPattern.Value;
                        counter += 1;
                        if (counter == offset)
                        {
                            break;
                        }
                    }
                }
            }

            return(result);
        }
Пример #2
0
        public ReferenceSeries Ref(ICustomData <double, double> newRefSeries, int index)
        {
            var result = new ReferenceSeries(newRefSeries.Name);

            result.Value = DataSeriesManager.GetCustom(newRefSeries) != null && DataSeriesManager.GetCustom(newRefSeries).Count > Math.Abs(index) ? DataSeriesManager.GetCustom(newRefSeries).GetValueByIndex(Math.Abs(index)) : -1;

            return(result);
        }
        public ICustomData <double, bool> CreateOrUpdateCross(HistoricalData currentData, ICustomData <double, double> a, ReferenceSeries b, CrossDirection direction)
        {
            ICustomData <double, bool> result;
            string name       = direction == CrossDirection.Down ? a.Name + CrossPartialName + b.Name : b.Name + CrossPartialName + a.Name;
            int    findResult = CrossDataSeries.FindIndex(x => x.Name == name);

            if (findResult != -1)
            {
                CrossDataSeries[findResult].GetValue(b.Value);
                result = CrossDataSeries[findResult];
            }
            else
            {
                result = CreateAndFillCross(currentData, a, b, direction);
            }

            return(result);
        }
        private ICustomData <double, bool> CreateAndFillCross(HistoricalData currentData, ICustomData <double, double> a, ReferenceSeries b, CrossDirection direction)
        {
            CrossDataSeries.Insert(0, new CROSS(a, b.Name, direction));
            (CrossDataSeries[0] as DataSeries <double, bool>).GetHistoricalData(currentData);
            FillCross(currentData, a);
            CrossDataSeries[0].GetValue(b.Value);

            return(CrossDataSeries[0]);
        }
Пример #5
0
        public ICustomData <double, bool> Cross(ReferenceSeries b, ICustomData <double, double> a)
        {
            var result = DataSeriesManager.CreateOrUpdateCross(HistoryDataSeries, a, b, CrossDirection.Up);

            return(result);
        }