当前位置: 首页>>代码示例>>C#>>正文


C# List.TakeLast方法代码示例

本文整理汇总了C#中Common.List.TakeLast方法的典型用法代码示例。如果您正苦于以下问题:C# List.TakeLast方法的具体用法?C# List.TakeLast怎么用?C# List.TakeLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common.List的用法示例。


在下文中一共展示了List.TakeLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: volumeDeclineAfterPriceRise

        /// <summary>Price and volume are going down after price rise.</summary>
        private bool volumeDeclineAfterPriceRise(List<Candle> candles)
        {
            const int MIN_CANDLES = 7;

            //Not enough data, can't reliably say
            if (candles.Count < MIN_CANDLES)
                return false;
            candles = candles.TakeLast(MIN_CANDLES).ToList();

            //Minimum rise of a candle to be considered significant. TODO: no magic here!
            const double SIGNIFICANT_RISE = 3.0;

            //In first 4 candles there are at least 3 significant rises and no significant fall
            const int MIN_RISE_CANDLES = 3;
            int rises = 0;
            double prevClosePrice = -1.0;           //(BUG?) hmm, that makes first candle automatic rise
            for (var c = 0; c < 4; c++)
            {
                if (candles[c].ClosingPrice > candles[c].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT && //rise
                    candles[c].ClosingPrice > prevClosePrice + SIGNIFICANT_RISE)
                {
                    prevClosePrice = candles[c].ClosingPrice;
                    rises++;
                }
                else if (candles[c].ClosingPrice < candles[c].OpeningPrice - PRICE_SIGNIFICANCE_LIMIT)
                    return false; //fall, good bye
            }
            if (rises < MIN_RISE_CANDLES)
                return false;

            //5th candle
            if (candles[4].ClosingPrice + PRICE_SIGNIFICANCE_LIMIT > candles[4].OpeningPrice)
                return false;   //Not fall
            //6th candle (before last)
            if (candles[5].ClosingPrice + PRICE_SIGNIFICANCE_LIMIT > candles[5].OpeningPrice || candles[5].Volume > candles[4].Volume)
                return false;   //Not fall or volume still rising

            //Present candle, most recent trade decides
            return candles[6].ClosingPrice < candles[5].ClosingPrice;
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:41,代码来源:MarketTrend.cs

示例2: isRising

        private bool isRising(List<Candle> candles)
        {
            const int MIN_CANDLES = 3;

            if (candles.Count < MIN_CANDLES)
                return false;
            candles = candles.TakeLast(MIN_CANDLES).ToList();

            //Present candle is significant rise
            if (candles.Last().ClosingPrice > candles.Last().OpeningPrice + 3.0*PRICE_SIGNIFICANCE_LIMIT)
                return true;

            //Previous 2 candles were rises and latest price was rise too //TODO: maybe something more sofisticated
            return candles[0].ClosingPrice > candles[0].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT &&
                   candles[1].ClosingPrice > candles[1].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT &&
                   candles[1].ClosingPrice < candles.Last().ClosingPrice;   //Most recent price decides
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:17,代码来源:MarketTrend.cs


注:本文中的Common.List.TakeLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。