示例#1
0
 public IEnumerable <IDataPoint> GetPoints(IDataSeries series)
 {
     foreach (var p in this)
     {
         yield return(p);
     }
 }
 internal DataSeriesObject(IDataSeries series, DateTime dateTime1, DateTime dateTime2, EventQueue queue, DataProcessor processor)
 {
     this.series = series;
     eventQueue  = queue;
     if (processor == null)
     {
         this.processor = new DataProcessor();
     }
     else
     {
         this.processor = processor;
     }
     if (!(dateTime1 == DateTime.MinValue) && (dateTime1 >= series.DateTime1))
     {
         index1 = series.GetIndex(dateTime1, SearchOption.Next);
     }
     else
     {
         index1 = 0L;
     }
     if (!(dateTime2 == DateTime.MaxValue) && (dateTime2 <= series.DateTime2))
     {
         index2 = series.GetIndex(dateTime2);
     }
     else
     {
         index2 = series.Count - 1L;
     }
     current         = index1;
     progressDelta   = (int)Math.Ceiling(Count() / 100.0);
     progressCount   = progressDelta;
     progressPercent = 0;
 }
        private void ltvDataSeries_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.InitChart();
            if (this.ltvDataSeries.SelectedItems.Count == 1)
            {
                IDataSeries dataSeries = (this.ltvDataSeries.SelectedItems[0] as DataSeriesViewItem).DataSeries;
                this.dataSeriesViewer.SetDataSeries(dataSeries);
                switch (DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType)
                {
                case DataType.Trade:
                    this.InitChart((ChartPanel) new TradeChartPanel(), dataSeries);
                    break;

                case DataType.Quote:
                    this.InitChart((ChartPanel) new QuoteChartPanel(), dataSeries);
                    break;

                case DataType.Bar:
                case DataType.Daily:
                    this.InitChart((ChartPanel) new BarChartPanel(), dataSeries);
                    break;
                }
            }
            else
            {
                this.dataSeriesViewer.SetDataSeries((IDataSeries)null);
            }
        }
示例#4
0
        protected override void OnBarUpdate()
        {
            IDataSeries ema1       = EMA(Input, Period);
            double      difference = ema1[0] - EMA(ema1, Period)[0];

            Value.Set(ema1[0] + difference);
        }
示例#5
0
 public ExportTask(IDataSeries dataSeries, string outputFileName)
 {
     this.DataSeries     = dataSeries;
     this.OutputFileName = outputFileName;
     this.State          = ExportTaskState.Waiting;
     this.Text           = string.Empty;
 }
示例#6
0
        internal override WorksheetSeriesDataProvider CreateSeriesDataProvider(IDataSeries dataSeries)
        {
            WorksheetSeriesDataProvider provider = base.CreateSeriesDataProvider(dataSeries);
            IDataSeries series1 = base.DataSeries;

            return(provider);
        }
示例#7
0
        public void Execute(TestParameters testParameters, TimeSpan duration, Action <double> fpsResult)
        {
            int pointCount  = testParameters.PointCount;
            int seriesCount = testParameters.PointCount;

            DataSeries = null;

            // Generate Data and mark time
            XyData[] xyData = new XyData[seriesCount];
            var      random = new Random();

            for (int i = 0; i < seriesCount; i++)
            {
                var generator = new RandomWalkGenerator(random.Next(0, int.MaxValue));
                xyData[i] = generator.GetRandomWalkSeries(pointCount);
            }

            // Append to SciChartSurface
            var allDataSeries = new IDataSeries[seriesCount];

            for (int i = 0; i < seriesCount; i++)
            {
                var dataSeries = new XyDataSeries <double, double>();
                dataSeries.Append(xyData[i].XData, xyData[i].YData);
                allDataSeries[i] = dataSeries;
            }
            DataSeries = allDataSeries;

            // Run test (just refresh)
            _testRunner        = new DispatcherTimerRunner(duration, () => this.sciChart.InvalidateElement(), fpsResult);
            sciChart.Rendered += _testRunner.OnSciChartRendered;
            _testRunner.Run();
        }
示例#8
0
        protected override void OnInit()
        {
            this.instrument = this.Key as Instrument;
            DataSeriesList dataSeries = this.instrument.GetDataSeries();

            this.template = Global.ChartManager.Templates["Default Template"];
            this.Text     = "Chart [" + ((FIXInstrument)this.instrument).Symbol + "]";
            this.instrumentListSource.AddInstrument(this.instrument);
            this.instrumentListSource.SelectedInstrument = this.instrument;
            IEnumerator enumerator = dataSeries.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    IDataSeries idataSeries = (IDataSeries)enumerator.Current;
                    string      key         = DataSeriesHelper.SeriesNameToString(idataSeries.Name);
                    if (key.StartsWith("Bar") || key == "Daily")
                    {
                        this.seriesNames.Add(key, idataSeries.Name);
                        this.instrumentListSource.AddSeries(this.instrument, new BarSeries(key));
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            this.instrumentListSource.Refresh();
        }
示例#9
0
        /// <summary>
        /// The mean reversion is the theory suggesting that prices and returns eventually move back towards the mean or average.
        /// </summary>
        public Mean_Reversion_Indicator Mean_Reversion_Indicator(IDataSeries input, System.Boolean isLongEnabled, System.Boolean isShortEnabled, System.Int32 bollinger_Period, System.Double bollinger_Standard_Deviation, System.Int32 momentum_Period, System.Int32 rSI_Period, System.Int32 rSI_Smooth, System.Int32 rSI_Level_Low, System.Int32 rSI_Level_High, System.Int32 momentum_Level_Low, System.Int32 momentum_Level_High)
        {
            var indicator = CachedCalculationUnits.GetCachedIndicator <Mean_Reversion_Indicator>(input, i => i.IsLongEnabled == isLongEnabled && i.IsShortEnabled == isShortEnabled && i.Bollinger_Period == bollinger_Period && Math.Abs(i.Bollinger_Standard_Deviation - bollinger_Standard_Deviation) <= Double.Epsilon && i.Momentum_Period == momentum_Period && i.RSI_Period == rSI_Period && i.RSI_Smooth == rSI_Smooth && i.RSI_Level_Low == rSI_Level_Low && i.RSI_Level_High == rSI_Level_High && i.Momentum_Level_Low == momentum_Level_Low && i.Momentum_Level_High == momentum_Level_High);

            if (indicator != null)
            {
                return(indicator);
            }

            indicator = new Mean_Reversion_Indicator
            {
                BarsRequired        = BarsRequired,
                CalculateOnBarClose = CalculateOnBarClose,
                Input                        = input,
                IsLongEnabled                = isLongEnabled,
                IsShortEnabled               = isShortEnabled,
                Bollinger_Period             = bollinger_Period,
                Bollinger_Standard_Deviation = bollinger_Standard_Deviation,
                Momentum_Period              = momentum_Period,
                RSI_Period                   = rSI_Period,
                RSI_Smooth                   = rSI_Smooth,
                RSI_Level_Low                = rSI_Level_Low,
                RSI_Level_High               = rSI_Level_High,
                Momentum_Level_Low           = momentum_Level_Low,
                Momentum_Level_High          = momentum_Level_High
            };
            indicator.SetUp();

            CachedCalculationUnits.AddIndicator2Cache(indicator);

            return(indicator);
        }
示例#10
0
        private int calcLastCross(IDataSeries series1, IDataSeries series2)
        {
            int crossedAbove = 0;

            for (crossedAbove = 0; crossedAbove < FastPlot.Count; crossedAbove++)
            {
                if (CrossAbove(series1, series2, crossedAbove))
                {
                    break;
                }
            }

            int crossedBelow = 0;

            for (crossedBelow = 0; crossedBelow < FastPlot.Count; crossedBelow++)
            {
                if (CrossBelow(series1, series2, crossedBelow))
                {
                    break;
                }
            }

            int lookBackPeriod = Math.Min(crossedAbove, crossedBelow);

            direction = -1;              // init direction, crossed below
            if (lookBackPeriod == crossedAbove)
            {
                direction = 1;                          // crossed above
            }
            return(lookBackPeriod);
        }
示例#11
0
        public double NtGetWaveAShort(IDataSeries ds, int barsAgo)
        {
            double rVal = 0.0;

            rVal = TTMWaveAOC(ds, false).Wave1[barsAgo];
            return(rVal);
        }
 internal DataSeriesObject(IDataSeries series, DateTime dateTime1, DateTime dateTime2, EventQueue queue, DataProcessor processor)
 {
     this.series = series;
     eventQueue = queue;
     if (processor == null)
     {
         this.processor = new DataProcessor();
     }
     else
     {
         this.processor = processor;
     }
     if (!(dateTime1 == DateTime.MinValue) && (dateTime1 >= series.DateTime1))
     {
         index1 = series.GetIndex(dateTime1, SearchOption.Next);
     }
     else
     {
         index1 = 0L;
     }
     if (!(dateTime2 == DateTime.MaxValue) && (dateTime2 <= series.DateTime2))
     {
         index2 = series.GetIndex(dateTime2);
     }
     else
     {
         index2 = series.Count - 1L;
     }
     current = index1;
     progressDelta = (int)Math.Ceiling(Count() / 100.0);
     progressCount = progressDelta;
     progressPercent = 0;
 }
示例#13
0
        public static DataObjectViewer GetViewer(IDataSeries dataSeries)
        {
            if (dataSeries == null)
            {
                return((DataObjectViewer)null);
            }
            switch (DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType)
            {
            case DataType.Trade:
                return((DataObjectViewer) new TradeViewer());

            case DataType.Quote:
                return((DataObjectViewer) new QuoteViewer());

            case DataType.Bar:
                return((DataObjectViewer) new BarViewer());

            case DataType.Daily:
                return((DataObjectViewer) new DailyViewer());

            case DataType.MarketDepth:
                return((DataObjectViewer) new MarketDepthViewer());

            default:
                return((DataObjectViewer)null);
            }
        }
示例#14
0
 public void Save(Instrument instrument, IDataSeries series, SaveMode option = SaveMode.Add)
 {
     for (long i = 0; i < series.Count; i++)
     {
         Server.Save(instrument, series[i], option);
     }
 }
示例#15
0
        public double NtGetWaveBLong(IDataSeries ds, int barsAgo)
        {
            double rVal = 0.0;

            rVal = TTMWaveBOC(ds, false).Wave2[barsAgo];
            return(rVal);
        }
示例#16
0
 private TimeSeries(string name, string description = "", int id = -1, IDataSeries series = null)
 {
     this.name        = name;
     this.description = description;
     Id          = id;
     this.series = series ?? new MemorySeries(name, description);
 }
示例#17
0
        private IDataSeries GetDataSeries()
        {
            string str1 = (string)null;

            switch (this.template.SymbolOptions.Option)
            {
            case SymbolOption.FileName:
                str1 = this.currentFile.Name;
                if (this.currentFile.Extension != string.Empty)
                {
                    str1 = str1.Substring(0, str1.IndexOf('.'));
                    break;
                }
                else
                {
                    break;
                }

            case SymbolOption.Column:
                str1 = this.currentItems[this.GetColumnIndex(ColumnType.Symbol)].Trim();
                break;

            case SymbolOption.Manually:
                str1 = this.template.SymbolOptions.Name;
                break;
            }
            if (this.template.OtherOptions.CreateInstrument && InstrumentManager.Instruments[str1] == null)
            {
                new Instrument(str1, APITypeConverter.InstrumentType.Convert(this.template.OtherOptions.InstrumentType)).Save();
            }
            string str2 = (string)null;

            switch (this.template.DataOptions.DataType)
            {
            case DataType.Trade:
                str2 = "Trade";
                break;

            case DataType.Quote:
                str2 = "Quote";
                break;

            case DataType.Bar:
                str2 = "Bar" + (object)'.' + ((object)(BarType)1).ToString() + (string)(object)'.' + this.template.DataOptions.BarSize.ToString();
                break;

            case DataType.Daily:
                str2 = "Daily";
                break;
            }
            string      str3        = str1 + (object)'.' + str2;
            IDataSeries idataSeries = DataManager.Server.GetDataSeries(str3) ?? DataManager.Server.AddDataSeries(str3);

            if (this.template.OtherOptions.ClearSeries && !this.clearedSeries.ContainsKey((object)idataSeries))
            {
                idataSeries.Clear();
                this.clearedSeries.Add((object)idataSeries, (object)true);
            }
            return(idataSeries);
        }
示例#18
0
		public ExportTask(IDataSeries dataSeries, string outputFileName)
		{
			this.DataSeries = dataSeries;
			this.OutputFileName = outputFileName;
			this.State = ExportTaskState.Waiting;
			this.Text = string.Empty;
		}
示例#19
0
        protected override void OnStartUp()
        {
            if (smooth > 1)
            {
                switch (maType)
                {
                case MovingAverageType.SMA: avg = SMA(Input, smooth);                     break;

                case MovingAverageType.SMMA: avg = SMMA(Input, smooth);            break;

                case MovingAverageType.TMA: avg = TMA(Input, smooth);                     break;

                case MovingAverageType.WMA: avg = WMA(Input, smooth);                     break;

                case MovingAverageType.VWMA: avg = VWMA(Input, smooth);            break;

                case MovingAverageType.TEMA: avg = TEMA(Input, smooth);            break;

                case MovingAverageType.HMA: avg = HMA(Input, smooth);                     break;

                case MovingAverageType.VMA: avg = VMA(Input, smooth, smooth);     break;

                default: avg = EMA(Input, smooth);                     break;
                }
            }
            else
            {
                avg = Input;
            }
        }
示例#20
0
 private TimeSeries(string name, string description = "", int id = -1, IDataSeries series = null)
 {
     this.name = name;
     this.description = description;
     Id = id;
     this.series = series ?? new MemorySeries(name, description);
 }
示例#21
0
        /// <summary>
        /// In this function we do all the work and send back the OrderAction.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public OrderAction?calculate(IDataSeries data, IDataSeries open, IDataSeries high, IOrder longorder, IOrder shortorder, int bollinger_period, double bollinger_standarddeviation, int momentum_period, int rsi_period, int rsi_smooth, int rsi_level_low, int rsi_level_high, int momentum_level_low, int momentum_level_high)
        {
            //Calculate BB
            Bollinger bb  = Bollinger(data, bollinger_standarddeviation, bollinger_period);
            Momentum  mom = Momentum(data, momentum_period);
            RSI       rsi = RSI(data, rsi_period, rsi_smooth);

            bb_lower  = bb.Lower[0];
            bb_middle = bb.Middle[0];
            bb_upper  = bb.Upper[0];

            //if (high[0] > open[1])
            //{
            if (mom[0] >= momentum_level_high && rsi[0] <= rsi_level_low && data[0] <= bb.Lower[0] && data[1] <= bb.Lower[1] && data[2] <= bb.Lower[2])
            {
                return(OrderAction.Buy);
            }
            else if (mom[0] <= momentum_level_low && rsi[0] >= rsi_level_high && data[0] >= bb.Upper[0] && data[1] >= bb.Upper[1] && data[2] >= bb.Upper[2])
            {
                return(OrderAction.SellShort);
            }
            else if (data[0] >= bb.Upper[0] && longorder != null)
            {
                //currently we left the building on the upper band, is it better if we switch to a stop?
                return(OrderAction.Sell);
            }
            else if (data[0] <= bb.Lower[0] && shortorder != null)
            {
                return(OrderAction.BuyToCover);
            }
            //}

            return(null);
        }
示例#22
0
        public virtual void Create(C1Chart chart, IDataSeries[] dss, int npts)
        {
            Reset(chart);

              IEnumerable x = null;

              for (int i = 0; i < dss.Length; i++)
              {
            DataSeries ds = null;
            if (i < chart.Data.Children.Count)
            {
              ds = (DataSeries)chart.Data.Children[i];
              dss[i].Update(ds, npts);
            }
            else
              ds = dss[i].Create(npts);

            XYDataSeries xds = ds as XYDataSeries;
            if (xds != null)
            {
              if (x == null)
            x = xds.XValuesSource;
              else
            xds.XValuesSource = x;
            }

            if( !chart.Data.Children.Contains(ds))
              chart.Data.Children.Add(ds);
              }
        }
 private SCIStackedMountainRenderableSeries GetRenderableSeries(IDataSeries dataSeries, uint fillColorStart, uint fillColorEbd)
 {
     return(new SCIStackedMountainRenderableSeries
     {
         DataSeries = dataSeries,
         AreaStyle = new SCILinearGradientBrushStyle(fillColorStart, fillColorEbd, SCILinearGradientDirection.Vertical),
     });
 }
示例#24
0
        public void Create(C1Chart chart, IDataSeries ds, int nser, int npts)
        {
            IDataSeries[] dss = new IDataSeries[nser];
              for (int i = 0; i < nser; i++)
            dss[i] = ds;

              Create(chart, dss, npts);
        }
示例#25
0
 private StackedMountainRenderableSeries GetRenderableSeries(IDataSeries dataSeries, Color fillColorStart, Color fillColorEbd)
 {
     return(new StackedMountainRenderableSeries
     {
         DataSeries = dataSeries,
         AreaStyle = new LinearGradientBrushStyle(0, 0, 0, 1, fillColorStart, fillColorEbd, TileMode.Clamp)
     });
 }
示例#26
0
 private StackedColumnRenderableSeries GetRenderableSeries(IDataSeries dataSeries, Color strokeColor, Color fillColor)
 {
     return(new StackedColumnRenderableSeries
     {
         DataSeries = dataSeries,
         StrokeStyle = new PenStyle.Builder(Activity).WithColor(strokeColor).WithThickness(1f, ComplexUnitType.Dip).Build(),
         FillBrushStyle = new SolidBrushStyle(fillColor)
     });
 }
 private StackedColumnRenderableSeries GetRenderableSeries(IDataSeries dataSeries, uint fillColor, uint strokeColor)
 {
     return(new StackedColumnRenderableSeries
     {
         DataSeries = dataSeries,
         StrokeStyle = new SolidPenStyle(Activity, strokeColor),
         FillBrushStyle = new SolidBrushStyle(fillColor)
     });
 }
示例#28
0
        /// <summary>
        /// Show seasonal trends
        /// </summary>
        public Seasonal_Indicator Seasonal_Indicator(IDataSeries input, SeasonalType seasonalType)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(LeadIndicator.Seasonal_Indicator(input, seasonalType));
        }
        /// <summary>
        /// Provides a signal in every even minute
        /// </summary>
        public DummyOneMinuteEven_Indicator DummyOneMinuteEven_Indicator(IDataSeries input)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(LeadIndicator.DummyOneMinuteEven_Indicator(input));
        }
        /// <summary>
        /// Qualitative Quantitative Estimation. QQE is a combination moving average RSI + ATR.
        /// </summary>
        public QQE QQE(IDataSeries input, System.Int32 rSI_Period, System.Int32 sF)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(LeadIndicator.QQE(input, rSI_Period, sF));
        }
示例#31
0
        /// <summary>
        /// The Minimum shows the minimum of the last n bars.
        /// </summary>
        /// <returns></returns>
        public MIN MIN(IDataSeries input, int period)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(_indicator.MIN(input, period));
        }
示例#32
0
        /// <summary>
        /// Compare the current value of an indicator to latest high value of the indicator in a defined period of time.
        /// </summary>
        public HighestHighValue_Indicator HighestHighValue_Indicator(IDataSeries input)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(LeadIndicator.HighestHighValue_Indicator(input));
        }
示例#33
0
        /// <summary>
        /// The mean reversion is the theory suggesting that prices and returns eventually move back towards the mean or average.
        /// </summary>
        public Mean_Reversion_Indicator Mean_Reversion_Indicator(IDataSeries input, System.Boolean isLongEnabled, System.Boolean isShortEnabled, System.Int32 bollinger_Period, System.Double bollinger_Standard_Deviation, System.Int32 momentum_Period, System.Int32 rSI_Period, System.Int32 rSI_Smooth, System.Int32 rSI_Level_Low, System.Int32 rSI_Level_High, System.Int32 momentum_Level_Low, System.Int32 momentum_Level_High)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(LeadIndicator.Mean_Reversion_Indicator(input, isLongEnabled, isShortEnabled, bollinger_Period, bollinger_Standard_Deviation, momentum_Period, rSI_Period, rSI_Smooth, rSI_Level_Low, rSI_Level_High, momentum_Level_Low, momentum_Level_High));
        }
示例#34
0
        public void Remove(string series, DateTime datetime)
        {
            IDataSeries dataSeries = this.file.Series[series];

            if (dataSeries != null)
            {
                dataSeries.Remove(datetime);
            }
        }
        /// <summary>
        /// Plots the Fibonacci Lines of the current session.,
        /// </summary>
        public Fibonacci_Current_Session Fibonacci_Current_Session(IDataSeries input)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(LeadIndicator.Fibonacci_Current_Session(input));
        }
示例#36
0
 /// <summary>
 ///     Froms the bar series to a double array.
 /// </summary>
 /// <param name="thebarserie">The thebarserie.</param>
 /// <returns></returns>
 public static double[] FromBarSeriestoDouble(IDataSeries thebarserie)
 {
     var outputtedseries = new double[thebarserie.Count];
     int index = 0;
     foreach (Data.Data.Bar abar in thebarserie)
     {
         outputtedseries[index] = abar.Close;
         index++;
     }
     return outputtedseries;
 }
示例#37
0
 public static void GenerateXGrids(this ICanvasRange range, IDataSeries series)
 {
     for (double dy = range.Ymin + range.YTick; dy < range.Ymax; dy += range.YTick)
     {
         Line gridLine = new Line
         {
             X1 = range.NormalizePoint(new Point(range.Xmin, dy)).X,
             Y1 = range.NormalizePoint(new Point(range.Xmin, dy)).Y,
             X2 = range.NormalizePoint(new Point(range.Xmax, dy)).X,
             Y2 = range.NormalizePoint(new Point(range.Xmax, dy)).Y
         };
         series.AddLinePattern(gridLine);
         range.ChartCanvas.Children.Add(gridLine);
     }
 }
示例#38
0
		protected override void OnStartUp()
		{
			if (smooth > 1)
				switch (maType)
				{
					case MovingAverageType.SMA	: avg = SMA(Input, smooth);			break;
					case MovingAverageType.SMMA	: avg = SMMA(Input, smooth);		break;
					case MovingAverageType.TMA	: avg = TMA(Input, smooth);			break;
					case MovingAverageType.WMA	: avg = WMA(Input, smooth);			break;
					case MovingAverageType.VWMA	: avg = VWMA(Input, smooth);		break;
					case MovingAverageType.TEMA	: avg = TEMA(Input, smooth);		break;
					case MovingAverageType.HMA	: avg = HMA(Input, smooth);			break;
					case MovingAverageType.VMA	: avg = VMA(Input, smooth, smooth);	break;
					default						: avg = EMA(Input, smooth);			break;
				}
			else
				avg = Input;
		}
示例#39
0
 public static DataObjectViewer GetViewer(IDataSeries dataSeries)
 {
   if (dataSeries == null)
     return (DataObjectViewer) null;
   switch (DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType)
   {
     case DataType.Trade:
       return (DataObjectViewer) new TradeViewer();
     case DataType.Quote:
       return (DataObjectViewer) new QuoteViewer();
     case DataType.Bar:
       return (DataObjectViewer) new BarViewer();
     case DataType.Daily:
       return (DataObjectViewer) new DailyViewer();
     case DataType.MarketDepth:
       return (DataObjectViewer) new MarketDepthViewer();
     default:
       return (DataObjectViewer) null;
   }
 }
示例#40
0
		public TimeSeries(string name, string title)
		{
			this.fColor = Color.Black;
			this.fMonitored = true;
			this.fToolTipEnabled = true;
			this.fToolTipFormat = "";
			this.fToolTipDateTimeFormat = "";
			this.fChildren = new ArrayList();

			this.fName = name;
			this.fTitle = title;
			this.fArray = new MemorySeries<object>();
		}
示例#41
0
 public void Save(Instrument instrument, IDataSeries series, SaveMode option = SaveMode.Add)
 {
     for (long i = 0; i < series.Count; i++)
         Server.Save(instrument, series[i], option);
 }
示例#42
0
文件: Engine.cs 项目: smther/FreeOQ
		protected virtual void Add(IDataSeries series, IDataObject obj)
		{
			series.Add(obj.DateTime, obj);
		}
        public void OutputSeries(out IDataSeries trades, out IDataSeries bids, out IDataSeries asks)
        {
            trades = new TickSeries();
            bids = new TickSeries();
            asks = new TickSeries();

            PbTickCodec codec = new PbTickCodec();
            int TradingDay = -1;
            int _lastTradeSize = 0;
            foreach (var s in Series)
            {
                if(TradingDay != s.TradingDay)
                {
                    _lastTradeSize = 0;
                    TradingDay = s.TradingDay;
                }
                var dateTime = codec.GetDateTime(s.ActionDay == 0 ? s.TradingDay : s.ActionDay).Add(codec.GetUpdateTime(s));
                var tick = PbTick2DepthMarketDataNClass(codec, s);

                if(SubscribeExternData)
                {
                    var trade = new TradeEx(dateTime, 0, _InstrumentId, tick.LastPrice, (int)tick.Volume);
                    trade.Size -= _lastTradeSize;
                    trade.DepthMarketData = tick;
                    trades.Add(trade);
                }
                else
                {
                    var trade = new Trade(dateTime, 0, _InstrumentId, tick.LastPrice, (int)tick.Volume);
                    trade.Size -= _lastTradeSize;
                    trades.Add(trade);
                }


                if (tick.Bids != null && tick.Bids.Length > 0)
                {
                    var bid = new Bid(dateTime, 0, _InstrumentId, tick.Bids[0].Price, tick.Bids[0].Size);
                    bids.Add(bid);
                }
                if (tick.Asks != null && tick.Asks.Length > 0)
                {
                    var ask = new Ask(dateTime, 0, _InstrumentId, tick.Asks[0].Price, tick.Asks[0].Size);
                    asks.Add(ask);
                }

                _lastTradeSize = (int)tick.Volume;
            }
        }
示例#44
0
        /// <summary>
        /// The anaMovingMedian (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
        /// </summary>
        /// <returns></returns>
        public anaMovingMedian anaMovingMedian(IDataSeries input, int period)
        {
            if (InInitialize && input == null)
                throw new ArgumentException(
                    "You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return _indicator.anaMovingMedian(input, period);
        }
示例#45
0
		public bool Contains(IDataSeries series)
		{
			return this.list.Contains(series);
		}
示例#46
0
		public int IndexOf(IDataSeries series)
		{
			return this.list.IndexOf(series);
		}
示例#47
0
		protected override void Add(IDataSeries series, IDataObject obj)
		{
			series.Update(obj.DateTime, obj);
		}
示例#48
0
		public SeriesObjectEventArgs(IDataSeries series, IDataObject obj) : base()
		{
			this.Series = series;
			this.Object = obj;
		}
示例#49
0
 public DataSeriesViewItem(IDataSeries dataSeries)
   : base(new string[4], 0)
 {
   this.dataSeries = dataSeries;
   this.Update();
 }
示例#50
0
        /// <summary>
        /// The anaMovingMedian (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
        /// </summary>
        /// <returns></returns>
        public anaMovingMedian anaMovingMedian(IDataSeries input, int period)
        {
            if (cacheanaMovingMedian != null)
                for (int idx = 0; idx < cacheanaMovingMedian.Length; idx++)
                    if (cacheanaMovingMedian[idx].Period == period && cacheanaMovingMedian[idx].EqualsInput(input))
                        return cacheanaMovingMedian[idx];

            lock (checkanaMovingMedian)
            {
                checkanaMovingMedian.Period = period;
                period = checkanaMovingMedian.Period;

                if (cacheanaMovingMedian != null)
                    for (int idx = 0; idx < cacheanaMovingMedian.Length; idx++)
                        if (cacheanaMovingMedian[idx].Period == period && cacheanaMovingMedian[idx].EqualsInput(input))
                            return cacheanaMovingMedian[idx];

                var indicator = new anaMovingMedian();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
            #if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
            #endif
                indicator.Input = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                var tmp = new anaMovingMedian[cacheanaMovingMedian == null ? 1 : cacheanaMovingMedian.Length + 1];
                if (cacheanaMovingMedian != null)
                    cacheanaMovingMedian.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheanaMovingMedian = tmp;
                return indicator;
            }
        }
示例#51
0
 /// <summary>
 /// The anaMovingMedian (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
 /// </summary>
 /// <returns></returns>
 public anaMovingMedian anaMovingMedian(IDataSeries input, int period)
 {
     return _indicator.anaMovingMedian(input, period);
 }
示例#52
0
 public DataSeriesObject(IDataSeries series, DateTime dateTime1, DateTime dateTime2, EventQueue dataQueue, DataProcessor processor)
 {
     this.queue = new EventQueue(EventQueueId.All, EventQueueType.Master, EventQueuePriority.Normal, 128, null);
     this.series = series;
     this.dataQueue = dataQueue;
     this.processor = processor ?? new DataProcessor();
     this.index1 = dateTime1 == DateTime.MinValue || dateTime1 < series.DateTime1 ? 0 : series.GetIndex(dateTime1, SearchOption.Next);
     this.index2 = dateTime2 == DateTime.MaxValue || dateTime2 > series.DateTime2 ? series.Count - 1 : series.GetIndex(dateTime2, SearchOption.Prev);
     this.current = this.index1;
     this.delta = (int)Math.Ceiling((this.index2 - this.index1 + 1) / 100.0);
     this.count = this.delta;
     this.percent = 0;
 }
示例#53
0
 public void SetDataSeries(IDataSeries series)
 {
   this.WF0dC3KCxx = series;
   this.PI6dU6Axph.SelectedItem = (object) Dhgssiwum3QkgMqvJP.kqFukiu92g(series);
   this.Text = string.Format(RNaihRhYEl0wUmAftnB.aYu7exFQKN(10402), (object) series.Name);
 }
示例#54
0
		public DataSeriesViewItem(IDataSeries dataSeries) : base(new string[1])
		{
			this.DataSeries = dataSeries;
			this.SubItems[0].Text = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol;
			this.ImageIndex = 0;
		}
示例#55
0
		public int Add(IDataSeries series)
		{
			return this.list.Add(series);
		}
示例#56
0
 public DataSeriesViewer()
 {
   this.InitializeComponent();
   this.dataSeries = (IDataSeries) null;
 }
示例#57
0
 public TimeSeries(IDataSeries series) : this(series.Name, series.Description, -1, series)
 {
 }
示例#58
0
 public void SetDataSeries(IDataSeries dataSeries)
 {
   this.dataSeries = dataSeries;
   this.Init();
 }
示例#59
0
		private void CalculateGD(IDataSeries input, DataSeries output)
		{
			output.Set((EMA(input, Period)[0] * (1 + VFactor)) - (EMA(EMA(input, Period), Period)[0] * VFactor));
		}
        public double MyStdDev(IDataSeries price, int p, AverageType at)
        {
            double avg;
            switch (at)
            {
                case AverageType.EMA	: avg = EMA(price, p)[0];			break;
                case AverageType.SMA	: avg = SMA(price, p)[0];			break;
                case AverageType.HMA	: avg = HMA(price, p)[0];			break;
                case AverageType.LinReg	: avg = LinReg(price, p)[0];		break;
                case AverageType.VOLMA	: avg = VOLMA(price, p)[0];			break;
                case AverageType.ATR	: avg = 1000 * ATR(price, p)[0];	break;
                case AverageType.StdDev	: avg = 1000 * StdDev(price, p)[0];	break;
                case AverageType.CCI	: avg = CCI(price, p)[0];			break;
                case AverageType.RSI	: avg = RSI(price, p, 3)[0];		break;
                case AverageType.ROC	: avg = ROC(price, p)[0];			break;
                default					: avg = WMA(price, p)[0];			break;
            }
            double sum = 0;
            for (int barsBack = Math.Min(CurrentBar, p - 1); barsBack >= 0; barsBack--)
                sum += (price[barsBack] - avg) * (price[barsBack] - avg);

            return (Math.Sqrt(sum / Math.Min(CurrentBar + 1, p)));
        }