HippoEngine en = new HippoEngine();
en.DataType = DataSourceType.Excel;
en.Query = "select * from [삼성전자2$]";
en.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=`C:\삼성전자2.xlsx`;Extended Properties=`Excel 12.0;HDR=YES`";
SeriesList sList = en.GetSeriesListOfStock(DataSourceType.Excel, "Date", "Start", "Close", "Low", "High");
sList.AxisFactor.YAxis.Direction = AxisDirection.Right;
// 이동평균선
sList.SeriesCollection.Add(new Series());
sList.SeriesCollection[1].ChartType = ChartType.Line;
sList.SeriesCollection[1].Points.Width = 0;
sList.SeriesCollection[1].Line.LineWidth = 2;
sList.SeriesCollection[1].SeriesColor = Color.YellowGreen;
int nCnt = sList.SeriesCollection[0].items.Count;
int nLine = 20; // 20 일 이동평균선
for(int i = 0; i < nCnt; i++)
{
SeriesItem item20 = new SeriesItem();
item20.Name = sList.SeriesCollection[0].items[i].Name;
for(int x = 0; x < nLine; x++)
{
try
{
item20.YValue += sList.SeriesCollection[0].items[i - x].YValue;
}
catch
{
item20.YValue = double.NaN;
}
}
item20.YValue = item20.YValue / nLine;
sList.SeriesCollection[1].items.Add(item20);
}
this.hHippoChart1.Titles.Label.Text = "히포차트 주식 - 20일 이동평균선";
this.hHippoChart1.LegendBox.Visible = false;
this.hHippoChart1.SeriesListDictionary.Add(sList);
this.hHippoChart1.DrawChart();
Dim en As New. HippoEngine()
en.DataType = DataSourceType.Excel
en.Query = "select * from [삼성전자2$]"
en.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=`C:\삼성전자2.xlsx`;Extended Properties=`Excel 12.0;HDR=YES`"
Dim sList As SeriesList = en.GetSeriesListOfStock(DataSourceType.Excel, "Date", "Start", "Close", "Low", "High")
sList.AxisFactor.YAxis.Direction = AxisDirection.Right
` 이동평균선
sList.SeriesCollection.Add(New Series())
sList.SeriesCollection(1).ChartType = ChartType.Line
sList.SeriesCollection(1).Points.Width = 0
sList.SeriesCollection(1).Line.LineWidth = 2
sList.SeriesCollection(1).SeriesColor = Color.YellowGreen
Dim nCnt As Integer = sList.SeriesCollection(0).items.Count
Dim nLine As Integer = 20
` 20 일 이동평균선
For i As Integer = 0 To nCnt - 1
Dim item20 As New. SeriesItem()
item20.Name = sList.SeriesCollection(0).items(i).Name
For x As Integer = 0 To nLine - 1
Try
item20.YValue += sList.SeriesCollection(0).items(i - x).YValue
Catch
item20.YValue = Double.NaN
End Try
Next
item20.YValue = item20.YValue / nLine
sList.SeriesCollection(1).items.Add(item20)
Next
Me.hHippoChart1.Titles.Label.Text = "히포차트 주식 - 20일 이동평균선"
Me.hHippoChart1.LegendBox.Visible = False
Me.hHippoChart1.SeriesListDictionary.Add(sList)
Me.hHippoChart1.DrawChart()