本文整理汇总了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;
}
示例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
}