Exemplo n.º 1
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="macds"></param>
        /// <param name="lmacds"></param>
        /// <param name="diffs"></param>
        public void InitByInput(float[] macds, float[] lmacds, float[] diffs)
        {
            var length = macds.Length;

            if (length > 0)
            {
                for (int i = 0; i < length; i++)
                {
                    var mInfo = new MacdInfo()
                    {
                        macd  = macds[i],
                        diff  = diffs[i],
                        lmacd = lmacds[i],
                        index = i
                    };
                    totalList.Add(mInfo);
                    if (mInfo.macd < 0)
                    {
                        greenMacdList.Add(mInfo);
                    }
                    if (mInfo.lmacd < 0)
                    {
                        largeGreenMacdList.Add(mInfo);
                    }
                }
                SepreteToGroupList(greenMacdList,
                                   (x, y) => x.witchGroup = y, // 所属于的macd块儿
                                   true);
                SepreteToGroupList(largeGreenMacdList,
                                   (x, y) => x.witchLargeGroup = y// 所属于的macd块儿
                                   );
            }
        }
Exemplo n.º 2
0
        private GreenMacdInfoGroup CreteGreenInfoGroup(int index, MacdInfo mInfo, GreenMacdInfoGroup lastGroup)
        {
            //创建组
            var group = new GreenMacdInfoGroup()
            {
                startMInfo = mInfo
            };

            group.lastGroup = lastGroup;//指向上一个group
            return(group);
        }
Exemplo n.º 3
0
        //遍历分割
        void SepreteToGroupList(MacdInfoList gmlist, Action <MacdInfo, GreenMacdInfoGroup> setGroupAction, bool sum = false)
        {
            int index = 0;
            GreenMacdInfoGroup current   = null;
            MacdInfo           tempMInfo = null;

            foreach (var item in gmlist)
            {
                if (current == null)
                {
                    current = CreteGreenInfoGroup(index, tempMInfo, null);
                }
                //当前与前一个之间有间隔
                else if (tempMInfo.index + 1 < item.index)
                {
                    //计算绿柱面积
                    if (sum)
                    {
                        current.sumVal = current.SumMacd();
                    }
                    index += 1;

                    //创建新组
                    current = CreteGreenInfoGroup(index, tempMInfo, current);
                }
                tempMInfo = item;
                if (setGroupAction != null)
                {
                    setGroupAction(tempMInfo, current);
                }
                current.endMInfo = tempMInfo;
                current.AddByCompare(tempMInfo);
            }
            if (current != null && sum)
            {
                current.sumVal = current.SumMacd();
            }
        }