private void UpdatePriceChart() { var chart = new XmlForCandleSticks(); List<PriceData> priceChartValues; if (_highValue == -1 && _lowValue == -1) { _highValue = double.Parse(_ticker.Buy.ToString()); _lowValue = double.Parse(_ticker.Buy.ToString()); _startValue = double.Parse(_ticker.Buy.ToString()); _endValue = double.Parse(_ticker.Buy.ToString()); } if (updateHigh(double.Parse(_ticker.Buy.ToString()))) { this._highValue = double.Parse(_ticker.Buy.ToString()); } if (updateLow(double.Parse(_ticker.Buy.ToString()))) { this._lowValue = double.Parse(_ticker.Buy.ToString()); } this._endValue = double.Parse(_ticker.Buy.ToString()); UpdateDynamicStick(); try { priceChartValues = chart.ReadAllElements(); if (chart.CountElement() != 29) { for (int countindex = 0; countindex < 28; countindex++) { chart.AddElement("", "00:00:00 AM", "0", "0", "0", "0"); } chart.AddElement(DateTime.Now.ToString("M/d/yyyy"), DateTime.Now.ToString("HH:mm:ss tt"),_startValue.ToString(),_endValue.ToString(),_highValue.ToString(),_lowValue.ToString()); } else { chart.DeleteElement(0); chart.AddElement(DateTime.Now.ToString("M/d/yyyy"), DateTime.Now.ToString("HH:mm:ss tt"), _startValue.ToString(), _endValue.ToString(), _highValue.ToString(), _lowValue.ToString()); } priceChart.Series["price"].Points.Clear(); priceChart.ChartAreas[0].AxisY.Minimum = _lowest - 0.5; priceChart.ChartAreas[0].AxisY.Maximum = _highest + 0.5; } catch (Exception) { } priceChartValues = chart.ReadAllElements(); for (int count = 0; count < priceChartValues.Count; count++) { priceChart.Series["price"].Points.AddXY(priceChartValues[count].time,double.Parse( priceChartValues[count].high)); priceChart.Series["price"].Points[count].YValues[1] = double.Parse(priceChartValues[count].low); priceChart.Series["price"].Points[count].YValues[2] = double.Parse(priceChartValues[count].start); priceChart.Series["price"].Points[count].YValues[3] = double.Parse(priceChartValues[count].end); } priceChart.Series["price"].Points.AddXY(DateTime.Now.ToString("HH:mm:ss tt"),double.Parse( _ticker.Buy.ToString())); priceChart.Series["price"].Points[29].YValues[1] = double.Parse(_ticker.Buy.ToString()); priceChart.Series["price"].Points[29].YValues[2] = double.Parse(_ticker.Buy.ToString()); priceChart.Series["price"].Points[29].YValues[3] = double.Parse(_ticker.Buy.ToString()); }
private void UpdateDynamicStick() { if (_clean == false) { var cleanchart = new XmlForCandleSticks(); cleanchart.CleanElement(); _clean = true; } if (this._highValue == -1 && _lowValue == -1) { _highValue = double.Parse(_ticker.Buy.ToString()); _lowValue = double.Parse(_ticker.Buy.ToString()); _startValue = double.Parse(_ticker.Buy.ToString()); _endValue = double.Parse(_ticker.Buy.ToString()); } if (this._highest == -1 && _lowest == -1) { _highest = double.Parse(_ticker.Buy.ToString()); _lowest = double.Parse(_ticker.Buy.ToString()); } if (updateHigh(double.Parse(_ticker.Buy.ToString()))) { this._highValue = double.Parse(_ticker.Buy.ToString()); } if (updateLow(double.Parse(_ticker.Buy.ToString()))) { this._lowValue = double.Parse(_ticker.Buy.ToString()); } this._endValue = double.Parse(_ticker.Buy.ToString()); var chart = new XmlForCandleSticks(); try { priceChart.ChartAreas[0].AxisY.Minimum = _lowest - 0.5; priceChart.ChartAreas[0].AxisY.Maximum = _highest + 0.5; try { priceChart.Series["price"].Points[29].SetValueXY(DateTime.Now.ToString("HH:mm:ss tt"), _highValue); priceChart.Series["price"].Points[29].YValues[1] = _lowValue; priceChart.Series["price"].Points[29].YValues[3] = _endValue; } catch (Exception) { for (int count = 0; count < 29; count++) { priceChart.Series["price"].Points.AddXY("00:00:00 AM", 0); priceChart.Series["price"].Points[count].YValues[1] = 0; priceChart.Series["price"].Points[count].YValues[2] = 0; priceChart.Series["price"].Points[count].YValues[3] = 0; } priceChart.Series["price"].Points.AddXY(DateTime.Now.ToString("HH:mm:ss tt"), double.Parse(_ticker.Buy.ToString())); priceChart.Series["price"].Points[29].YValues[1] = double.Parse(_ticker.Buy.ToString()); priceChart.Series["price"].Points[29].YValues[2] = double.Parse(_ticker.Buy.ToString()); priceChart.Series["price"].Points[29].YValues[3] = double.Parse(_ticker.Buy.ToString()); } } catch (Exception) {} }