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.AxisFactor.YAxis.IsZeroStartScale = false;
sList.GraphArea.Grid.IsBackGridColor = false;
sList.AxisFactor.AxisItems.Add(new Axis(AxisType.Ytype));
sList.AxisFactor.AxisItems[0].Decimalpoint = 0;
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.Pink;
sList.SeriesCollection[1].AxisIndex = 1;
sList.AxisFactor.AxisItems[0].Markers.Add(new AxisMarker("RSI - 매도라인", 70));
sList.AxisFactor.AxisItems[0].Markers.Add(new AxisMarker("RSI - 매수라인", 30));
sList.AxisFactor.AxisItems[0].Markers[0].TextFormat.Alignment = StringAlignment.Near;
sList.AxisFactor.AxisItems[0].Markers[1].TextFormat.Alignment = StringAlignment.Near;
sList.AxisFactor.AxisItems[0].Markers[0].TextFormat.LineAlignment = StringAlignment.Near;
sList.AxisFactor.AxisItems[0].Markers[1].TextFormat.LineAlignment = StringAlignment.Near;
sList.AxisFactor.AxisItems[0].Markers[1].Line.LineColor = Color.Red;
sList.AxisFactor.AxisItems[0].Markers[1].Label.ForeColor = Color.Red;
int nCnt = sList.SeriesCollection[0].items.Count;
for(int i = 0; i < nCnt; i++)
{
SeriesItem itemRSI = new SeriesItem();
itemRSI.Name = sList.SeriesCollection[0].items[i].Name;
try
{
int N = 10; // 보통 14로 한다고 하는데 네이버에 데이터가 10일이라 일단 맞춤. 수정 하시면 됩니다
double U_sum = 0;
double D_sum = 0;
double AU = 0; // 평균
double AD = 0; // 평균
for(int a = 0; a < N; a++)
{
double U = 0;
double D = 0;
double temp = sList.SeriesCollection[0].items[i - a].YValue - sList.SeriesCollection[0].items[i - a - 1].YValue;
if (temp > 0)
{
U = temp;
U_sum += U;
}
else if (temp < 0)
{
D = Math.Abs(temp);
D_sum += D;
}
}
AU = U_sum / N;
AD = D_sum / N;
itemRSI.YValue = (AU / (AU + AD)) * 100;
}
catch { itemRSI.YValue = double.NaN; }
sList.SeriesCollection[1].items.Add(itemRSI);
}
this.hHippoChart1.Designer.InnerBackColor = Color.Yellow;
this.hHippoChart1.Titles.Label.Text = "히포차트 주식 - RSI 보조지표";
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.AxisFactor.YAxis.IsZeroStartScale = False
sList.GraphArea.Grid.IsBackGridColor = False
sList.AxisFactor.AxisItems.Add(New Axis(AxisType.Ytype))
sList.AxisFactor.AxisItems(0).Decimalpoint = 0
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.Pink
sList.SeriesCollection(1).AxisIndex = 1
sList.AxisFactor.AxisItems(0).Markers.Add(New AxisMarker("RSI - 매도라인", 70))
sList.AxisFactor.AxisItems(0).Markers.Add(New AxisMarker("RSI - 매수라인", 30))
sList.AxisFactor.AxisItems(0).Markers(0).TextFormat.Alignment = StringAlignment.Near
sList.AxisFactor.AxisItems(0).Markers(1).TextFormat.Alignment = StringAlignment.Near
sList.AxisFactor.AxisItems(0).Markers(0).TextFormat.LineAlignment = StringAlignment.Near
sList.AxisFactor.AxisItems(0).Markers(1).TextFormat.LineAlignment = StringAlignment.Near
sList.AxisFactor.AxisItems(0).Markers(1).Line.LineColor = Color.Red
sList.AxisFactor.AxisItems(0).Markers(1).Label.ForeColor = Color.Red
Dim nCnt As Integer = sList.SeriesCollection(0).items.Count
For i As Integer = 0 To nCnt - 1
Dim itemRSI As New. SeriesItem()
itemRSI.Name = sList.SeriesCollection(0).items(i).Name
Try
Dim N As Integer = 10
` 보통 14로 한다고 하는데 네이버에 데이터가 10일이라 일단 맞춤. 수정 하시면 됩니다
Dim U_sum As Double = 0
Dim D_sum As Double = 0
Dim AU As Double = 0
` 평균
Dim AD As Double = 0
` 평균
For a As Integer = 0 To N - 1
Dim U As Double = 0
Dim D As Double = 0
Dim temp As Double = sList.SeriesCollection(0).items(i - a).YValue - sList.SeriesCollection(0).items(i - a - 1).YValue
If temp > 0 Then
U = temp
U_sum += U
ElseIf temp < 0 Then
D = Math.Abs(temp)
D_sum += D
End If
Next
AU = U_sum / N
AD = D_sum / N
itemRSI.YValue = (AU / (AU + AD)) * 100
Catch
itemRSI.YValue = Double.NaN
End Try
sList.SeriesCollection(1).items.Add(itemRSI)
Next
Me.hHippoChart1.Designer.InnerBackColor = Color.Yellow
Me.hHippoChart1.Titles.Label.Text = "히포차트 주식 - RSI 보조지표"
Me.hHippoChart1.LegendBox.Visible = False
Me.hHippoChart1.SeriesListDictionary.Add(sList)
Me.hHippoChart1.DrawChart()