1. 볼랜저 추가

2. 영호 사는거 파는거 디테일 추가
3. 사고 파는 Result 필드 추가 및 데이터 갖고 있게끔만 처리 (추후 Form에 올릴수 있게 할 예정)
This commit is contained in:
kyh
2024-06-19 12:51:35 +09:00
parent a6334dcc15
commit d83a01b8e2
4 changed files with 169 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
using BitgetApi.Data;
using BitgetAPI.Data;
using BitgetAPI.Data.IndicatorData;
using System;
@@ -21,6 +22,9 @@ namespace BitgetAPI.IndicatorConditionSetup
public int CandleLegnth4 { get; set; } = 4;
// 기간
public int CandleLegnth72 { get; set; } = 72;
// 기간
public int CandleLegnth12 { get; set; } = 12;
// 가격
public CommonProperty.CandlePriceType MACandlePriceType { get; set; }
@@ -38,6 +42,7 @@ namespace BitgetAPI.IndicatorConditionSetup
candleData.movingAverageDataList = new Dictionary<int, MovingAverageData>();
candleData.movingAverageDataList.Add(CandleLegnth4, new MovingAverageData());
candleData.movingAverageDataList.Add(CandleLegnth12, new MovingAverageData());
candleData.movingAverageDataList.Add(CandleLegnth24, new MovingAverageData());
candleData.movingAverageDataList.Add(CandleLegnth72, new MovingAverageData());
}
@@ -51,8 +56,60 @@ namespace BitgetAPI.IndicatorConditionSetup
candleData.movingAverageDataList[item.Key] = new MovingAverageData();
candleData.movingAverageDataList[item.Key].Value = datas.Sum(i => i.Close) / item.Key;
CalBolangerValue(datas, candleData.movingAverageDataList[item.Key], datas.Count - 1, item.Key);
}
}
//볼랜저 계산
public void CalBolangerValue(List<CandleData> data, MovingAverageData mvData, int i, int period)
{
double total_average = 0;
if (i < period - 1)
{
return;
}
for (int t = i - period + 1; t < i; t++)
{
total_average += data[t].Close;
}
total_average += data[i].Close;
double average = total_average / period;
double t_Close = 0;
//오버렙 값 구하기 위한 변수
double sum = 0;
double powSum = 0;
int j;
for (j = (i - period + 1); j < i; j++)
{
t_Close += Math.Pow(data[j].Close - average, 2);
sum += data[j].Close;
powSum += Math.Pow(data[j].Close, 2);
}
t_Close += Math.Pow(data[j].Close - average, 2);
//하향선
if (mvData.BolangerType == 0)
{
mvData.BolangerValue = average - mvData.BolangerSquared * Math.Sqrt(t_Close / period);
}
//상향선
else if (mvData.BolangerType == 1)
{
mvData.BolangerValue = average + mvData.BolangerSquared * Math.Sqrt(t_Close / period);
}
//기준선
else if (mvData.BolangerType == 2)
{
mvData.BolangerValue = average;
}
}
}
}