diff --git a/Million Prototype/Form1.cs b/Million Prototype/Form1.cs index 85818a6..0303823 100644 --- a/Million Prototype/Form1.cs +++ b/Million Prototype/Form1.cs @@ -282,7 +282,7 @@ namespace Million_Prototype var indicatorSetUpList = distinctIndicator.Where(t => t.MCandleTimeType == key).ToList(); foreach (var setup in indicatorSetUpList) { - setup.excute(dic[key]); + setup.excute(dic[key], true); } } diff --git a/Million/IndicatorConditionSetup/BolingerConditionSetup.cs b/Million/IndicatorConditionSetup/BolingerConditionSetup.cs index 8095eb1..977f111 100644 --- a/Million/IndicatorConditionSetup/BolingerConditionSetup.cs +++ b/Million/IndicatorConditionSetup/BolingerConditionSetup.cs @@ -66,8 +66,14 @@ namespace Million.IndicatorConditionSetup int i = 0; if(last) { + if (data.Count() < Period) + return; - i = data.Count() - Period - 1; + if(data[data.Count()-2].IndicatorDic.ContainsKey(bolKeyName)) + { + 단일볼렌저(data, data.Count() - 1); + return; + } } for (; i < data.Count(); i++) @@ -126,7 +132,66 @@ namespace Million.IndicatorConditionSetup } } } + public void 단일볼렌저(List data, int i) + { + var bolKeyName = GetKeyName(); + var bol = data[i].IndicatorDic[bolKeyName] = new IndicatorData(); + double total_average = 0; + if (i < Period - 1) + { + return; + } + for (int t = i - Period + 1; t < i; t++) + { + total_average += data[t].EndValue; + } + var total_Open = total_average + data[i].StartValue; + var total_High = total_average + data[i].HighValue; + var total_Low = total_average + data[i].LowValue; + total_average += data[i].EndValue; + + double average = total_average / Period; + double average_Open = total_Open / Period; + double average_High = total_High / Period; + double average_Low = total_Low / Period; + double t_Open = 0; + double t_Close = 0; + double t_High = 0; + double t_Low = 0; + //오버렙 값 구하기 위한 변수 + double sum = 0; + double powSum = 0; + + int j; + for (j = (i - Period + 1); j < i; j++) + { + t_Open += Math.Pow(data[j].EndValue - average_Open, 2); + t_High += Math.Pow(data[j].EndValue - average_High, 2); + t_Low += Math.Pow(data[j].EndValue - average_Low, 2); + t_Close += Math.Pow(data[j].EndValue - average, 2); + sum += data[j].EndValue; + powSum += Math.Pow(data[j].EndValue, 2); + } + t_Open += Math.Pow(data[j].StartValue - average_Open, 2); + t_High += Math.Pow(data[j].HighValue - average_High, 2); + t_Low += Math.Pow(data[j].LowValue - average_Low, 2); + t_Close += Math.Pow(data[j].EndValue - average, 2); + + bol.startValue = average_Open + Squared * Math.Sqrt(t_Open / Period); + bol.highValue = average_High + Squared * Math.Sqrt(t_High / Period); + bol.lowValue = average_Low + Squared * Math.Sqrt(t_Low / Period); + bol.value = average + Squared * Math.Sqrt(t_Close / Period); + + IndicatorData.OverChecker(data[i], bol, data[i - 1].IndicatorDic[bolKeyName].indicator_over); + + if (bol.overStatus != CommonProperty.OverStatus.None) + { + bol.overlapValue = getTargetValue(Period, sum, Squared, powSum); + } + + + } private double getBol(List candleDatas,double sum,double candle) { diff --git a/Million/IndicatorConditionSetup/IchimokuConditionSetup.cs b/Million/IndicatorConditionSetup/IchimokuConditionSetup.cs index edac8ef..4c74175 100644 --- a/Million/IndicatorConditionSetup/IchimokuConditionSetup.cs +++ b/Million/IndicatorConditionSetup/IchimokuConditionSetup.cs @@ -79,8 +79,13 @@ namespace Million.IndicatorConditionSetup int dataIndex = 0; if(last) { - dataIndex = dataCount - Displacement - LaggingSpan2Period; + if (data[data.Count() - 2].IndicatorDic.ContainsKey(key)) + { + dataIndex = dataCount - Displacement-1; + } + } + for (; dataIndex < dataCount; dataIndex++) { var saveIndex = dataIndex + Displacement; diff --git a/Million/IndicatorConditionSetup/MovingAverageConditionSetup.cs b/Million/IndicatorConditionSetup/MovingAverageConditionSetup.cs index ccc3667..8c7fe3f 100644 --- a/Million/IndicatorConditionSetup/MovingAverageConditionSetup.cs +++ b/Million/IndicatorConditionSetup/MovingAverageConditionSetup.cs @@ -92,7 +92,6 @@ namespace Million.IndicatorConditionSetup return IndexString + key; return key; } - /// /// 단순 이평선 계산 /// TODO : 지수 가중 @@ -110,7 +109,26 @@ namespace Million.IndicatorConditionSetup double dividValue = Period * (Period + 1) / 2; var endValueList = new List(); - for (int i = 0; i < data.Count(); i++) + int i = 0; + if (last) + { + if(i+Period>= data.Count()) + { + return; + } + if (data[data.Count() - 2].IndicatorDic.ContainsKey(movingKeyName)) + { + i = data.Count() - 1; + for(int j= data.Count()-Period;j