public PricePaneModel(PriceSeries prices) : base(PRICES, "$%.4f", true) { var stockPrices = new OhlcDataSeries <DateTime, double> { SeriesName = "EUR/USD" }; stockPrices.Append(prices.TimeData, prices.OpenData, prices.HighData, prices.LowData, prices.CloseData); AddRenderableSeries(new SCIFastCandlestickRenderableSeries { DataSeries = stockPrices, YAxisId = PRICES, StrokeUpStyle = new SCISolidPenStyle(0xff52cc54, 1f), FillUpBrushStyle = new SCISolidBrushStyle(0xa052cc54), StrokeDownStyle = new SCISolidPenStyle(0xffe26565, 1f), FillDownBrushStyle = new SCISolidBrushStyle(0xd0e26565) }); var maLow = new XyDataSeries <DateTime, double> { SeriesName = "Low Line" }; maLow.Append(prices.TimeData, prices.CloseData.MovingAverage(50)); AddRenderableSeries(new SCIFastLineRenderableSeries { DataSeries = maLow, StrokeStyle = new SCISolidPenStyle(0xFFFF3333, 1f), YAxisId = PRICES }); var maHigh = new XyDataSeries <DateTime, double> { SeriesName = "High Line" }; maHigh.Append(prices.TimeData, prices.CloseData.MovingAverage(200)); AddRenderableSeries(new SCIFastLineRenderableSeries { DataSeries = maHigh, StrokeStyle = new SCISolidPenStyle(0xFF33DD33, 1f), YAxisId = PRICES }); var priceMarker = new SCIAxisMarkerAnnotation { Position = stockPrices.YValues.ValueAt(stockPrices.Count - 1).ToComparable(), Style = { BackgroundColor = 0xFFFF3333.ToColor() }, YAxisId = PRICES }; var maLowMarker = new SCIAxisMarkerAnnotation { Position = maLow.YValues.ValueAt(maLow.Count - 1).ToComparable(), Style = { BackgroundColor = 0xFFFF3333.ToColor() }, YAxisId = PRICES }; var maHighMarker = new SCIAxisMarkerAnnotation { Position = maHigh.YValues.ValueAt(maHigh.Count - 1).ToComparable(), Style = { BackgroundColor = 0xFF33DD33.ToColor() }, YAxisId = PRICES }; Annotations.Add(priceMarker); Annotations.Add(maLowMarker); Annotations.Add(maHighMarker); }
private void CreateMainPriceChart() { // Create an XAxis and YAxis for our chart var xAxis = new SCICategoryDateTimeAxis { Style = { DrawMajorGridLines = false }, GrowBy = new SCIDoubleRange(0, 0.1) }; var yAxis = new SCINumericAxis { AutoRange = SCIAutoRange.Always }; // Create RenderableSeries to render the data var ohlcSeries = new SCIFastOhlcRenderableSeries { DataSeries = _ohlcDataSeries, StrokeUpStyle = new SCISolidPenStyle(StrokeUpColor, StrokeThickness), StrokeDownStyle = new SCISolidPenStyle(StrokeDownColor, StrokeThickness), }; var movingAverage50Series = new SCIFastLineRenderableSeries { DataSeries = _xyDataSeries, StrokeStyle = new SCISolidPenStyle(0xFFFF6600, 1.0f) }; // Create axis markers annotations to show the last values on real-time chart //TODO Position -> Y1Value, color property should be on annotation itself _smaAxisMarker = new SCIAxisMarkerAnnotation { Position = 0d, YAxisId = yAxis.AxisId }; _smaAxisMarker.Style.BackgroundColor = SmaSeriesColor.ToColor(); _ohlcAxisMarker = new SCIAxisMarkerAnnotation { Position = 0d, YAxisId = yAxis.AxisId }; _ohlcAxisMarker.Style.BackgroundColor = StrokeUpColor.ToColor(); using (MainSurface.SuspendUpdates()) { MainSurface.XAxes.Add(xAxis); MainSurface.YAxes.Add(yAxis); MainSurface.RenderableSeries.Add(ohlcSeries); MainSurface.RenderableSeries.Add(movingAverage50Series); MainSurface.Annotations.Add(_ohlcAxisMarker); MainSurface.Annotations.Add(_smaAxisMarker); // Populate some pinch and touch interactions. Pinch to zoom, drag to pan and double-tap to zoom extents MainSurface.ChartModifiers = new SCIChartModifierCollection { new SCIXAxisDragModifier(), new SCIZoomPanModifier { Direction = SCIDirection2D.XDirection }, new SCIZoomExtentsModifier(), new SCILegendModifier { Orientation = SCIOrientation.Horizontal, Position = SCILegendPosition.Bottom, StyleOfItemCell = new SCILegendCellStyle { SeriesNameFont = UIFont.FromName("Helvetica", 10f) } } }; } }