private WCFBarData GetData(string code, string id, string symbol, int max) { WCFBarData data = new WCFBarData { ID = id, Symbol = symbol, Data = new List <WCFBar>() }; if (code == "E5136ED93A4B4687AD12089A5416D21A")//Simple validation - hardcoded password { try { var hyst = frmMain.CSIFeed.GetHistory(new CSIData.HistoryRequest { ID = id, MaxAmount = max, period = 1, Symbol = symbol }); foreach (var itm in hyst) { data.Data.Add(new WCFBar { Close = itm.Close, High = itm.High, Low = itm.Low, Open = itm.Open, TimeStamp = itm.TimeStamp, Volume = itm.Volume }); } } catch (Exception e) { LogFile.WriteToLog(string.Format("Message: {0}, \n StackTrace: {1}", e.Message, e.StackTrace)); } } return(data); }
void webCient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(e.Error.Message, "Data Service Connection Error", MessageBoxButton.OK); } else { if (!string.IsNullOrEmpty(e.Result)) { var data = WCFBarData.XmlDeSerialize <WCFBarData>(e.Result); { data.Data = HCM401kData.TA.BarConverter.ConvertToWeekly(data.Data); m_Chart.CreateChart(data); } } DataClient.GetAvailableTickersAsync(); } }
public void CreateChart(WCFBarData value, bool showVolume = false, bool isLine = false) { InfoMessage(true, "Loading ..."); CurrentBars = value; if (value != null && value.Data != null && value.Data.Count > 2 && !string.IsNullOrEmpty(value.Symbol)) { txtSymbol.Text = value.Symbol; brdrNoData.Visibility = System.Windows.Visibility.Collapsed; if (!initiated) { NonInitChartValue = value; } else { _stockChartX.ClearAll(); _stockChartX.Symbol = value.Symbol; Brush chartPanelsBrush = new SolidColorBrush(Colors.Black); TopPanel = _stockChartX.AddChartPanel(); TopPanel.Background = chartPanelsBrush; TopPanel.CloseBox = false; TopPanel.MaximizeBox = false; TopPanel.MinimizeBox = false; if (showVolume) { VolumePanel = _stockChartX.AddChartPanel(ChartPanel.PositionType.AlwaysBottom); VolumePanel.Background = chartPanelsBrush; } TopPanel.Name = "TopPanel"; if (showVolume) { VolumePanel.Name = "VolumePanel"; } if (isLine) { OHLCSeries = new Series[] { _stockChartX.AddLineSeries(value.Symbol, TopPanel.Index, SeriesTypeOHLC.Unknown) } } ; else { OHLCSeries = _stockChartX.AddOHLCSeries(_stockChartX.Symbol, TopPanel.Index); } for (int i = 0; i < OHLCSeries.Length; i++) { OHLCSeries[i].Selectable = false; } if (showVolume) { VolumeSeries = _stockChartX.AddVolumeSeries(_stockChartX.Symbol, VolumePanel.Index); } for (int row = 0; row < value.Data.Count; row++) { var bd = value.Data[row]; if (isLine) { _stockChartX.AppendValue(_stockChartX.Symbol, bd.TimeStamp.ToLocalTime(), bd.Close); } else { _stockChartX.AppendOHLCValues(_stockChartX.Symbol, bd.TimeStamp.ToLocalTime(), bd.Open, bd.High, bd.Low, bd.Close); } if (showVolume) { _stockChartX.AppendVolumeValue(_stockChartX.Symbol, bd.TimeStamp.ToLocalTime(), bd.Volume); } } if (showVolume) { VolumeSeries.StrokeColor = Colors.White; VolumeSeries.StrokeThickness = 1; } for (int i = 0; i < OHLCSeries.Length; i++) { OHLCSeries[i].StrokeColor = Colors.White; } if (_stockChartX[SeriesTypeOHLC.Close] != null) { _stockChartX[SeriesTypeOHLC.Close].TickBox = TickBoxPosition.Right; } //_stockChartX.SeriesTickBoxValuePresenterTemplate = new ControlTemplate(); // Note: If dividing volume by millions as we have above, // you should add an "M" to the volume panel like this: //StockChartX1.VolumePostfix = "M"; // M for "millions" // You could also divide by 1000 and show "K" for "thousands". _stockChartX.VolumePostfixLetter = "M"; //"M"; _stockChartX.VolumeDivisor = (int)1E6; //1;//(int)1E6; _stockChartX.ScalePrecision = IsForexPair(value.Symbol) ? 5 : 2; _stockChartX.RightChartSpace = 5; _stockChartX.RealTimeXLabels = false; _stockChartX.SetPanelHeight(0, _stockChartX.ActualHeight * 0.75); Brush fbrush = new SolidColorBrush(Color.FromArgb(0x33, 0xCC, 0xCC, 0xCC)); _stockChartX.GridStroke = fbrush; _stockChartX.ThreeDStyle = false; fbrush = new SolidColorBrush(Colors.White); _stockChartX.InfoPanelLabelsBackground = fbrush; _stockChartX.OptimizePainting = true; _stockChartX.UseVolumeUpDownColors = true; _stockChartX.InfoPanelPosition = FixedInfoPanel ? InfoPanelPositionEnum.FixedPosition : InfoPanelPositionEnum.FollowMouse; _stockChartX.MaxVisibleRecords = int.MaxValue;// _stockChartX.RecordCount; _stockChartX.Update(); var lbl = _stockChartX.GetPanelByIndex(0).ChartPanelLabel; lbl.FontSize = 60; Canvas.SetLeft(lbl, 20); Canvas.SetTop(lbl, 20); fbrush = new SolidColorBrush(Color.FromArgb(0x33, 0xFF, 0xFF, 0xCC)); lbl.Foreground = fbrush; lbl.Text = _stockChartX.Symbol; this._stockChartX.LayoutUpdated += _stockChartX_LayoutUpdated; } } else { InfoMessage(true, "No Data"); } InfoMessage(false); }
public static List <DataResult> AroonOscillator(WCFBarData value, int period)