private int updateIndicatorChart() { int result = 0; try { m_series_indi.Points.Clear(); if (m_boxer == null) { result = 1; return(result); } CandleBuffer candleBuf = m_boxer.getCandleBuffer(); if (candleBuf == null) { result = 1; return(result); } if (!candleBuf.isFullBuffer()) { result = 1; return(result); } int candle_full_cnt = candleBuf.getCandleCount(); if (candle_full_cnt <= 0) { result = -1; return(result); } int beg_idx = 0; if (candle_full_cnt >= 100) { beg_idx = candle_full_cnt - 100; } int candle_cnt = 0; double y_min = 0.0; double y_max = 0.0; //foreach (Candlestick candle in candleBuf.getCandleList()) for (int i = beg_idx; i < candle_full_cnt; i++) { Candlestick candle = candleBuf.getCandle(i); if (candle == null) { continue; } double value = Math.Floor(candle.ma_top_increase_rate); DataPoint dp_value = new DataPoint(candle_cnt, value); m_series_indi.Points.Add(dp_value); // 表示範囲を算出 if (candle_cnt == 0) { y_max = value; y_min = 0.0; } else { if (y_max < value) { y_max = value; } if (y_min > value) { y_min = value; } } candle_cnt++; } m_series_indi.ChartArea = "IndicatorChart"; m_indicatorArea.AxisY.Minimum = Math.Floor(y_min); m_indicatorArea.AxisY.Maximum = Math.Floor(y_max); this.chart1.Series.Add(m_series_indi); } catch (Exception ex) { Console.WriteLine(ex); result = -1; } finally { } return(result); }
private int updateCandleChart() { int result = 0; try { m_series_ltp.Points.Clear(); m_series_ema.Points.Clear(); m_series_ema_sub.Points.Clear(); m_series_bollHigh.Points.Clear(); m_series_bollLow.Points.Clear(); m_series_bollHigh_top.Points.Clear(); m_series_bollLow_top.Points.Clear(); m_series_min.Points.Clear(); m_series_max.Points.Clear(); m_series_body_min.Points.Clear(); m_series_body_max.Points.Clear(); m_series_entry.Points.Clear(); if (m_boxer == null) { result = 1; return(result); } CandleBuffer candleBuf = m_boxer.getCandleBuffer(); if (candleBuf == null) { result = 1; return(result); } Candlestick curCandle = candleBuf.getLastCandle(); if (curCandle == null) { result = 1; return(result); } double range_min = curCandle.range_min; double range_max = curCandle.range_max; double body_min = curCandle.body_min; double body_max = curCandle.body_max; double entry_price = m_boxer.getEntryPrice(); if (!candleBuf.isFullBuffer()) { result = 1; return(result); } int candle_full_cnt = candleBuf.getCandleCount(); if (candle_full_cnt <= 0) { result = -1; return(result); } int beg_idx = 0; if (candle_full_cnt >= 100) { beg_idx = candle_full_cnt - 100; } int candle_cnt = 0; double y_min = 0.0; double y_max = 0.0; //foreach (Candlestick candle in candleBuf.getCandleList()) for (int i = beg_idx; i < candle_full_cnt; i++) { Candlestick candle = candleBuf.getCandle(i); if (candle == null) { continue; } // High Low Open Closeの順番で配列を作成 double[] values = new double[4] { Math.Round(candle.high, 0), Math.Round(candle.low, 0), Math.Round(candle.open, 0), Math.Round(candle.last, 0) }; // 日付、四本値の配列からDataPointのインスタンスを作成 DataPoint dp = new DataPoint(candle_cnt, values); m_series_ltp.Points.Add(dp); DataPoint dp_ema = new DataPoint(candle_cnt, Math.Round(candle.ema, 0)); m_series_ema.Points.Add(dp_ema); DataPoint dp_ema_sub = new DataPoint(candle_cnt, Math.Round(candle.ema_sub, 0)); m_series_ema_sub.Points.Add(dp_ema_sub); DataPoint dp_bollHigh = new DataPoint(candle_cnt, Math.Round(candle.boll_high, 0)); m_series_bollHigh.Points.Add(dp_bollHigh); DataPoint dp_bollLow = new DataPoint(candle_cnt, Math.Round(candle.boll_low, 0)); m_series_bollLow.Points.Add(dp_bollLow); DataPoint dp_bollHigh_top = new DataPoint(candle_cnt, Math.Round(candle.boll_high_top, 0)); m_series_bollHigh_top.Points.Add(dp_bollHigh_top); DataPoint dp_bollLow_top = new DataPoint(candle_cnt, Math.Round(candle.boll_low_top, 0)); m_series_bollLow_top.Points.Add(dp_bollLow_top); DataPoint dp_min = new DataPoint(candle_cnt, Math.Round(range_min, 0)); m_series_min.Points.Add(dp_min); DataPoint dp_max = new DataPoint(candle_cnt, Math.Round(range_max, 0)); m_series_max.Points.Add(dp_max); DataPoint dp_body_min = new DataPoint(candle_cnt, Math.Round(body_min, 0)); m_series_body_min.Points.Add(dp_body_min); DataPoint dp_body_max = new DataPoint(candle_cnt, Math.Round(body_max, 0)); m_series_body_max.Points.Add(dp_body_max); if (entry_price > double.Epsilon) { DataPoint dp_entry = new DataPoint(candle_cnt, Math.Round(entry_price, 0)); m_series_entry.Points.Add(dp_entry); } double elem_max = candle.boll_high; double elem_min = candle.boll_low; if (candle.high > candle.boll_high) { elem_max = candle.high; } if (candle.low < candle.boll_low) { elem_min = candle.low; } if (candle.boll_high_top > elem_max) { elem_max = candle.boll_high_top; } if (candle.boll_low_top < elem_min) { elem_min = candle.boll_low_top; } // 表示範囲を算出 if (candle_cnt == 0) { y_max = elem_max; y_min = elem_min; } else { if (y_max < elem_max) { y_max = elem_max; } if (y_min > elem_min) { y_min = elem_min; } } candle_cnt++; } m_area.AxisY.Minimum = Math.Round(Math.Floor((y_min - 1000) / 1000) * 1000); m_area.AxisY.Maximum = Math.Round(Math.Ceiling((y_max + 1000) / 1000) * 1000); this.chart1.Series.Add(m_series_ltp); this.chart1.Series.Add(m_series_ema); this.chart1.Series.Add(m_series_ema_sub); this.chart1.Series.Add(m_series_bollHigh); this.chart1.Series.Add(m_series_bollLow); this.chart1.Series.Add(m_series_bollHigh_top); this.chart1.Series.Add(m_series_bollLow_top); this.chart1.Series.Add(m_series_min); this.chart1.Series.Add(m_series_max); this.chart1.Series.Add(m_series_body_min); this.chart1.Series.Add(m_series_body_max); if (entry_price > double.Epsilon) { this.chart1.Series.Add(m_series_entry); } // Console.WriteLine("update Chart. y_min={0} y_max={1}", y_min, y_max); } catch (Exception ex) { Console.WriteLine(ex); result = -1; } finally { } return(result); }