示例#1
0
        private void TransitionToDownFromUp(BarAnalyzerResult result)
        {
            // get lowest low
            IBarDatum highest = DataList
                                .Where(e => e.Index >= WorkingBar.Index && e.Index <= result.WorkingBar.Index)
                                .OrderByDescending(e => e.High)
                                .First();

            HighList.Add(highest);

            Transition(result, highest);
        }
示例#2
0
        private void Update(BarAnalyzerResult result)
        {
            // set WorkingBar to result.WorkingBar if CurrentTrend is Unknown or result.IsValidTrendBar is true
            // if (!HighList.Any() && !LowList.Any())
            if (CurrentTrendType == Trend.TrendType.Unknown)
            {
                if (result.Trend == Trend.TrendType.Up)
                {
                    LowList.Add(result.WorkingBar);
                }
                else if (result.Trend == Trend.TrendType.Down)
                {
                    HighList.Add(result.WorkingBar);
                }

                CurrentTrendType = result.Trend;

                WorkingBar = result.WorkingBar;

                MoveList.Add(Move.Open(MoveList.Count, result.WorkingBar, (int)result.Trend));
            }
            else
            {
                if (result.IsValidTrendBar)
                {
                    WorkingBar = result.WorkingBar;
                    // currentTrend: undetermined: currentTrend = trend
                    // currentTrend: Up: if( trend.Down) changecurrentTrend to down and add bar Highest high series I {Working ... barDatum}
                    // currentTrend: Down: if (trend.up) changcurrentTrend to up and add bar with Lowest low in series {WorkingBar .. barDatum}
                    switch (CurrentTrendType)
                    {
                    case Trend.TrendType.Up:
                    {
                        if (result.Trend == Trend.TrendType.Down)
                        {
                            TransitionToDownFromUp(result);
                        }
                    }
                    break;

                    case Trend.TrendType.Down:
                    {
                        if (result.Trend == Trend.TrendType.Up)
                        {
                            TransitionToUpFromDown(result);
                        }
                    }

                    break;
                    }
                }
            }
        }