private void Run(object o) { string itemCode = (string)o; string lastPrice = ""; LimitedList <double> ll3 = new LimitedList <double>(3); LimitedList <double> ll5 = new LimitedList <double>(5); LimitedList <double> ll7 = new LimitedList <double>(7); int rnd = ItemCodeSet.GetItemRoundNum(itemCode); while (true) { if (!SiseStorage.Instance.Prices.ContainsKey(itemCode)) { System.Threading.Thread.Sleep(1000); continue; } var priceQueue = SiseStorage.Instance.Prices[itemCode]; if (priceQueue.Count == 0) { System.Threading.Thread.Sleep(100); continue; } CurrentPrice price; var isDequeue = priceQueue.TryDequeue(out price); if (isDequeue) { if (lastPrice == price.price) { continue; } lastPrice = price.price; double d = Math.Round(Convert.ToDouble(lastPrice), rnd); ll3.Insert(d); ll5.Insert(d); ll7.Insert(d); price.price3 = ll3.Count == 3 ? Math.Round(ll3.Average(), rnd) : 0; price.price5 = ll3.Count == 5 ? Math.Round(ll5.Average(), rnd) : 0; price.price7 = ll3.Count == 7 ? Math.Round(ll7.Average(), rnd) : 0; SiseEvents.Instance.OnSiseHandler(itemCode, price); PPStorage.Instance.Add(itemCode, price.DTime, (Single)Math.Round(Convert.ToSingle(price.price), rnd)); if (isSiseBinding) { BindSise(itemCode, price); } } } }
private void RunKr(object o) { string itemCode = (string)o; string lastPrice = ""; LimitedList <double> ll3 = new LimitedList <double>(3); LimitedList <double> ll5 = new LimitedList <double>(5); LimitedList <double> ll7 = new LimitedList <double>(7); int rnd = ItemCodeSet.GetItemRoundNum(itemCode); while (isRunKr) { try { if (!SiseStorage.Instance.PricesKr.ContainsKey(itemCode)) { System.Threading.Thread.Sleep(1000); continue; } var priceQueue = SiseStorage.Instance.PricesKr[itemCode]; if (priceQueue.Count == 0) { System.Threading.Thread.Sleep(100); continue; } CurrentPrice price; var isDequeue = priceQueue.TryDequeue(out price); if (isDequeue) { if (lastPrice == price.price) { continue; } lastPrice = price.price; double d = Math.Round(Convert.ToDouble(lastPrice), rnd); if (!ll3.Contains(d)) { ll3.Insert(d); } if (!ll5.Contains(d)) { ll5.Insert(d); } if (!ll7.Contains(d)) { ll7.Insert(d); } price.price3 = Math.Round(ll3.Average(), rnd); price.price5 = Math.Round(ll5.Average(), rnd); price.price7 = Math.Round(ll7.Average(), rnd); SiseEvents.Instance.OnSiseHandler(itemCode, price); if (isSiseBinding) { BindSise(itemCode, price); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } }
public override void View() { pnlScroll.Visible = IsAutoScrollX; if (ChartData == null) { return; } resistanceList.Clear(); supportList.Clear(); resistanceAvgList.Clear(); supportAvgList.Clear(); pmForceList.Clear(); PPUtils.SetRangeHighLowPrice(ChartData, 18); PPUtils.SetRangeHighLowPrice(ChartDataSub, 18); //resistanceList.Add(PPUtils.GetResistancePrice(pList, 3)); //resistanceList.Add(PPUtils.GetResistancePrice(mList, 3)); //supportList.Add(PPUtils.GetSupportPrice(pList, 3)); //supportList.Add(PPUtils.GetSupportPrice(mList, 3)); //resistanceAvgList.Add(PPUtils.GetResistancePrice(ChartDataSub, 3)); //supportAvgList.Add(PPUtils.GetSupportPrice(ChartDataSub, 3)); smartDataList.Clear(); wisdomDataList.Clear(); smartBDataList.Clear(); wisdomBDataList.Clear(); SmartCandleData preSmartData = null; WisdomCandleData preWisdomData = null; for (int i = 0; i < ChartDataSub.Count; i++) { var cData = ChartDataSub[i]; SmartCandleData smartData = new SmartCandleData(cData.ItemCode, cData.OpenPrice, cData.HighPrice, cData.LowPrice, cData.ClosePrice, cData.Volume, cData.DTime, preSmartData); smartDataList.Add(smartData); preSmartData = smartData; WisdomCandleData wisdomData = new WisdomCandleData(cData.ItemCode, cData.OpenPrice, cData.HighPrice, cData.LowPrice, cData.ClosePrice, cData.Volume, cData.DTime, preWisdomData); wisdomDataList.Add(wisdomData); preWisdomData = wisdomData; } preSmartData = null; preWisdomData = null; for (int i = 0; i < ChartDataSub2.Count; i++) { var cData = ChartDataSub2[i]; SmartCandleData smartData = new SmartCandleData(cData.ItemCode, cData.OpenPrice, cData.HighPrice, cData.LowPrice, cData.ClosePrice, cData.Volume, cData.DTime, preSmartData); smartBDataList.Add(smartData); preSmartData = smartData; WisdomCandleData wisdomData = new WisdomCandleData(cData.ItemCode, cData.OpenPrice, cData.HighPrice, cData.LowPrice, cData.ClosePrice, cData.Volume, cData.DTime, preWisdomData); wisdomBDataList.Add(wisdomData); preWisdomData = wisdomData; } double preSPrice1 = 0; double preSPrice2 = 0; double preSPrice3 = 0; double nextSPrice1 = 0; double nextSPrice2 = 0; double nextSPrice3 = 0; double preMassAvg = 0; double preQuantumAvg = 0; int uItemCount = 0; int dItemCount = 0; LimitedList <double> dList1 = new LimitedList <double>(5); LimitedList <double> dList2 = new LimitedList <double>(5); ThreeCandlePattern threePatttern = new ThreeCandlePattern(); double pmForce = 0; double prePMForce = 0; pmForceList.Add(0); pmForceList.Add(0); pmForceList.Add(0); pmForceList.Add(0); for (int i = 4; i < ChartData.Count; i++) { var item = ChartData[i]; var itemAvg = ChartDataSub[i]; var itemAvg2 = ChartDataSub2[i]; var smart = smartDataList[i]; var wisdom = wisdomDataList[i]; var smartB = smartBDataList[i]; var wisdomB = wisdomBDataList[i]; dList1.Insert((smart.Variance_ChartPrice1 + smart.Variance_ChartPrice2 + smart.Variance_ChartPrice3) / 3.0); dList2.Insert(smart.Variance_ChartPrice3); if ((i + 1) < ChartData.Count) { var nsmart = smartDataList[i + 1]; nextSPrice1 = nsmart.Variance_ChartPrice1; nextSPrice2 = nsmart.Variance_ChartPrice2; nextSPrice3 = nsmart.Variance_ChartPrice3; } else { nextSPrice1 = 0; nextSPrice2 = 0; nextSPrice3 = 0; } int idx = chart.Series["candleBasic"].Points.AddXY(item.DTime, item.HighPrice, item.LowPrice, item.OpenPrice, item.ClosePrice); string diceChar = item.GetSpaceType(item); //string diceChar = getDiceChar(itemAvg); chart.Series["candleBasic"].Points[idx].Label = diceChar; //chart.Series["lineElectronForce1"].Points.AddXY(item.DTime, item.T_ElectronForceAvg); chart.Series["lineElectronForce1"].Points.AddXY(itemAvg.DTime, itemAvg.T_ElectronForceAvg); chart.Series["lineElectronForce2"].Points.AddXY(itemAvg.DTime, 0); if (item.VirtualData) { SetDataPointColor(chart.Series["candleBasic"].Points[idx], Color.Black, Color.Transparent, Color.Black, 1); } if (diceChar == "★") { chart.Series["candleBasic"].Points[idx].LabelForeColor = Color.Red; } chart.Series["lineMess"].Points.AddXY(itemAvg.DTime, itemAvg.T_MassAvg); chart.Series["lineQuantum"].Points.AddXY(itemAvg.DTime, itemAvg.T_QuantumAvg); chart.Series["lineMessHL"].Points.AddXY(itemAvg.DTime , itemAvg.T_MassAvg + (Math.Abs(itemAvg.T_MassAvg - itemAvg.HighPrice) - Math.Abs(itemAvg.T_MassAvg - itemAvg.LowPrice))); chart.Series["lineCandleRangeH"].Points.AddXY(item.DTime, Math.Round(item.RangeHighPrice, RoundLength)); chart.Series["lineCandleRangeL"].Points.AddXY(item.DTime, Math.Round(item.RangeLowPrice, RoundLength)); chart.Series["candleAverage"].Points.AddXY(itemAvg.DTime, itemAvg.HighPrice, itemAvg.LowPrice, itemAvg.OpenPrice, itemAvg.ClosePrice); diceChar = itemAvg.GetSpaceType(itemAvg); chart.Series["candleAverage"].Points[idx].Label = diceChar; if (diceChar == "★") { chart.Series["candleAverage"].Points[idx].LabelForeColor = Color.Red; } chart.Series["lineCandleAvgRangeH"].Points.AddXY(itemAvg.DTime, Math.Round(itemAvg.RangeHighPrice, RoundLength)); chart.Series["lineCandleAvgRangeL"].Points.AddXY(itemAvg.DTime, Math.Round(itemAvg.RangeLowPrice, RoundLength)); chart.Series["candleBAverage"].Points.AddXY(itemAvg2.DTime, itemAvg2.HighPrice, itemAvg2.LowPrice, itemAvg2.OpenPrice, itemAvg2.ClosePrice); chart.Series["lineSmartEnergy1"].Points.AddXY(smart.DTime, smart.Variance_ChartPrice1); chart.Series["lineSmartEnergy2"].Points.AddXY(smart.DTime, smart.Variance_ChartPrice2); chart.Series["lineSmartEnergy3"].Points.AddXY(smart.DTime, smart.Variance_ChartPrice3); chart.Series["lineSmartAvg1"].Points.AddXY(smart.DTime, Math.Round(dList1.Average(), RoundLength)); chart.Series["lineSmartAvg2"].Points.AddXY(smart.DTime, Math.Round(dList2.Average(), RoundLength)); chart.Series["lineSmartZero"].Points.AddXY(smart.DTime, 0); chart.Series["lineSmartBEnergy2"].Points.AddXY(smartB.DTime, smartB.Variance_ChartPrice2); chart.Series["lineWisdomBEnergy"].Points.AddXY(wisdomB.DTime, wisdomB.Variance_ChartPrice); var bitem = ChartData[i - 1]; chart.Series["stackHL"].Points.AddXY(item.DTime, item.TotalLength); chart.Series["stackHL2"].Points.AddXY(item.DTime, (bitem.TotalLength - item.TotalLength) <= 0 ? 0 : (bitem.TotalLength - item.TotalLength)); if (itemAvg.PlusMinusType == PlusMinusTypeEnum.양) { pmForce += itemAvg.HeadLength; } else if (itemAvg.PlusMinusType == PlusMinusTypeEnum.음) { pmForce -= itemAvg.LegLength; } //else //{ // if (itemAvg.PreCandleItem.PlusMinusType == PlusMinusTypeEnum.양) // pmForce -= itemAvg.PreCandleItem.BodyLength; // else if (itemAvg.PreCandleItem.PlusMinusType == PlusMinusTypeEnum.음) // pmForce += itemAvg.PreCandleItem.BodyLength; //} chart.Series["linePlusMinusForce"].Points.AddXY(itemAvg.DTime, pmForce); chart.Series["linePlusMinusZero"].Points.AddXY(itemAvg.DTime, 0); if (pmForce > prePMForce) { chart.Series["linePlusMinusForce"].Points[idx].Color = Color.Red; } else if (pmForce < prePMForce) { chart.Series["linePlusMinusForce"].Points[idx].Color = Color.Blue; } else { chart.Series["linePlusMinusForce"].Points[idx].Color = Color.Black; } pmForceList.Add(pmForce); prePMForce = pmForce; //if (SelectedPType == "국내지수") //{ // if (preSPrice1 > preSPrice2 && preSPrice2 > preSPrice3) // { // if (smart.Variance_ChartPrice1 > smart.Variance_ChartPrice2 && smart.Variance_ChartPrice2 > smart.Variance_ChartPrice3) // { // if (preSPrice3 < smart.Variance_ChartPrice3) // { // chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Red; // chart.Series["lineSmartEnergy3"].Points[idx].Label = "▲"; // } // } // } // if (preSPrice1 < preSPrice2 && preSPrice2 < preSPrice3) // { // if (smart.Variance_ChartPrice1 < smart.Variance_ChartPrice2 && smart.Variance_ChartPrice2 < smart.Variance_ChartPrice3) // { // if (preSPrice3 > smart.Variance_ChartPrice3) // { // chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Blue; // chart.Series["lineSmartEnergy3"].Points[idx].Label = "▼"; // } // } // } //} //if (SelectedPType == "해외지수") //{ // if (preSPrice1 > preSPrice2 && preSPrice2 > preSPrice3) // { // if (smart.Variance_ChartPrice1 > smart.Variance_ChartPrice2 && smart.Variance_ChartPrice2 > smart.Variance_ChartPrice3) // { // if (preSPrice3 < smart.Variance_ChartPrice3) // { // chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Red; // chart.Series["lineSmartEnergy3"].Points[idx].Label = "▲"; // } // } // } // if (preSPrice1 < preSPrice2 && preSPrice2 < preSPrice3) // { // if (smart.Variance_ChartPrice1 < smart.Variance_ChartPrice2 && smart.Variance_ChartPrice2 < smart.Variance_ChartPrice3) // { // if (preSPrice3 > smart.Variance_ChartPrice3) // { // chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Blue; // chart.Series["lineSmartEnergy3"].Points[idx].Label = "▼"; // } // } // } //} if (SelectedPType == "해외선물" || SelectedPType == "암호화폐") { uItemCount++; dItemCount++; if (smart.Variance_ChartPrice3 < 0 && preSPrice3 >= smart.Variance_ChartPrice3 && (nextSPrice3 != 0 && nextSPrice3 >= smart.Variance_ChartPrice3)) { bool isRange = true; //if (TimeInterval == TimeIntervalEnum.Minute_30 && smart.Variance_ChartPrice3 <= -30) isRange = true; //if (TimeInterval == TimeIntervalEnum.Hour_01 && smart.Variance_ChartPrice3 <= -50) isRange = true; //if (TimeInterval == TimeIntervalEnum.Hour_02 && smart.Variance_ChartPrice3 <= -60) isRange = true; //if (TimeInterval == TimeIntervalEnum.Hour_05 && smart.Variance_ChartPrice3 <= -70) isRange = true; //if (TimeInterval == TimeIntervalEnum.Day && smart.Variance_ChartPrice3 <= -100) isRange = true; //if (TimeInterval == TimeIntervalEnum.Week && smart.Variance_ChartPrice3 <= -300) isRange = true; if (uItemCount >= 5 && isRange) { uItemCount = 0; chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Red; chart.Series["lineSmartEnergy3"].Points[idx].Label = "▲"; } } if (smart.Variance_ChartPrice3 > 0 && preSPrice3 <= smart.Variance_ChartPrice3 && (nextSPrice3 != 0 && nextSPrice3 <= smart.Variance_ChartPrice3)) { bool isRange = true; //if (TimeInterval == TimeIntervalEnum.Minute_30 && smart.Variance_ChartPrice3 >= 30) isRange = true; //if (TimeInterval == TimeIntervalEnum.Hour_01 && smart.Variance_ChartPrice3 >= 50) isRange = true; //if (TimeInterval == TimeIntervalEnum.Hour_02 && smart.Variance_ChartPrice3 >= 60) isRange = true; //if (TimeInterval == TimeIntervalEnum.Hour_05 && smart.Variance_ChartPrice3 >= 70) isRange = true; //if (TimeInterval == TimeIntervalEnum.Day && smart.Variance_ChartPrice3 >= 100) isRange = true; //if (TimeInterval == TimeIntervalEnum.Week && smart.Variance_ChartPrice3 >= 300) isRange = true; if (dItemCount >= 5 && isRange) { dItemCount = 0; chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Blue; chart.Series["lineSmartEnergy3"].Points[idx].Label = "▼"; } } } //if (SelectedPType == "국내업종") //{ // if (preSPrice1 > preSPrice2 && preSPrice2 > preSPrice3) // { // if (smart.Variance_ChartPrice1 > smart.Variance_ChartPrice2 && smart.Variance_ChartPrice2 > smart.Variance_ChartPrice3) // { // if (preSPrice3 < smart.Variance_ChartPrice3) // { // chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Red; // chart.Series["lineSmartEnergy3"].Points[idx].Label = "▲"; // } // } // } // if (preSPrice1 < preSPrice2 && preSPrice2 < preSPrice3) // { // if (smart.Variance_ChartPrice1 < smart.Variance_ChartPrice2 && smart.Variance_ChartPrice2 < smart.Variance_ChartPrice3) // { // if (preSPrice3 > smart.Variance_ChartPrice3) // { // chart.Series["lineSmartEnergy3"].Points[idx].LabelForeColor = Color.Blue; // chart.Series["lineSmartEnergy3"].Points[idx].Label = "▼"; // } // } // } //} preSPrice1 = smart.Variance_ChartPrice1; preSPrice2 = smart.Variance_ChartPrice2; preSPrice3 = smart.Variance_ChartPrice3; preMassAvg = itemAvg.T_MassAvg; preQuantumAvg = itemAvg.T_QuantumAvg; var dataPoint = chart.Series["candleBasic"].Points[idx]; var dataPointAvg = chart.Series["candleAverage"].Points[idx]; dataPoint.Tag = item; if (item.PlusMinusType == PlusMinusTypeEnum.양 && item.YinAndYang == PlusMinusTypeEnum.양) { SetDataPointColor(dataPoint, Color.Red, Color.Red, Color.Red, 2); } else if (item.PlusMinusType == PlusMinusTypeEnum.음 && item.YinAndYang == PlusMinusTypeEnum.양) { SetDataPointColor(dataPoint, Color.Blue, Color.Blue, Color.Blue, 2); } else if (item.PlusMinusType == PlusMinusTypeEnum.양) { SetDataPointColor(dataPoint, Color.Red, Color.Red, Color.White, 2); } else if (item.PlusMinusType == PlusMinusTypeEnum.음) { SetDataPointColor(dataPoint, Color.Blue, Color.Blue, Color.White, 2); } else { SetDataPointColor(dataPoint, Color.Black, Color.Black, Color.White, 2); } if (itemAvg.PlusMinusType == PlusMinusTypeEnum.양) { SetDataPointColor(dataPointAvg, Color.Red, Color.Red, Color.White, 2); } else if (itemAvg.PlusMinusType == PlusMinusTypeEnum.음) { SetDataPointColor(dataPointAvg, Color.Blue, Color.Blue, Color.White, 2); } else { SetDataPointColor(dataPointAvg, Color.Black, Color.Black, Color.White, 2); } } SetTrackBar(); SetScrollBar(); DisplayView(); //ViewPattern(); IsLoaded = true; base.View(); }