本文整理汇总了C#中StockSerie.CalculateBuySellMomemtum方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.CalculateBuySellMomemtum方法的具体用法?C# StockSerie.CalculateBuySellMomemtum怎么用?C# StockSerie.CalculateBuySellMomemtum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSerie
的用法示例。
在下文中一共展示了StockSerie.CalculateBuySellMomemtum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
using (MethodLogger ml = new MethodLogger(this))
{
FloatSerie fastMom = stockSerie.CalculateBuySellMomemtum((int)this.parameters[0], (bool)this.parameters[1]);
this.series[0] = fastMom;
this.Series[0].Name = this.Name;
if (this.series[0] != null && this.Series[0].Count > 0)
{
this.CreateEventSeries(stockSerie.Count);
FloatSerie upExLimit = new FloatSerie(stockSerie.Count, this.SerieNames[1]);
FloatSerie downExLimit = new FloatSerie(stockSerie.Count, this.SerieNames[2]);
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
for (int i = 1; i < this.SeriesCount; i++)
{
this.Series[i] = new FloatSerie(stockSerie.Count, this.SerieNames[i]);
}
FloatSerie indicatorToDecorate = this.Series[0];
float exhaustionSellLimit = indicatorToDecorate[0];
float exhaustionBuyLimit = indicatorToDecorate[0];
float exhaustionBuyPrice = highSerie[0];
float exhaustionSellPrice = lowSerie[0];
float exFadeOut = (100.0f - (float)this.parameters[2]) / 100.0f;
float previousValue = indicatorToDecorate[0];
float currentValue;
for (int i = 1; i < indicatorToDecorate.Count - 1; i++)
{
currentValue = indicatorToDecorate[i];
if (currentValue < previousValue)
{
if (indicatorToDecorate.IsBottom(i))
{
if (currentValue <= exhaustionSellLimit)
{
// This is an exhaustion selling
exhaustionSellPrice = lowSerie[i];
exhaustionSellLimit = currentValue;
}
else
{
exhaustionSellLimit *= exFadeOut;
}
exhaustionBuyLimit *= exFadeOut;
}
else
{ // trail exhaustion limit down
exhaustionSellLimit = Math.Min(currentValue, exhaustionSellLimit);
exhaustionBuyLimit *= exFadeOut;
}
}
else if (currentValue > previousValue)
{
if (indicatorToDecorate.IsTop(i))
{
if (currentValue >= exhaustionBuyLimit)
{
// This is an exhaustion selling
exhaustionBuyPrice = highSerie[i];
exhaustionBuyLimit = currentValue;
}
else
{
exhaustionSellLimit *= exFadeOut;
}
exhaustionBuyLimit *= exFadeOut;
}
else
{ // trail exhaustion limit up
exhaustionBuyLimit = Math.Max(currentValue, exhaustionBuyLimit);
exhaustionSellLimit *= exFadeOut;
}
}
else
{
exhaustionSellLimit *= exFadeOut;
exhaustionBuyLimit *= exFadeOut;
}
previousValue = currentValue;
upExLimit[i] = exhaustionBuyLimit;
downExLimit[i] = exhaustionSellLimit;
}
upExLimit[indicatorToDecorate.Count - 1] = exhaustionBuyLimit;
downExLimit[indicatorToDecorate.Count - 1] = exhaustionSellLimit;
this.series[1] = upExLimit;
this.series[2] = downExLimit;
for (int i = 5; i < indicatorToDecorate.Count - 1; i++)
{
this.eventSeries[0][i] = fastMom[i - 1] == upExLimit[i - 1] && fastMom[i] < fastMom[i - 1];
this.eventSeries[1][i] = fastMom[i - 1] == downExLimit[i - 1] && fastMom[i] > fastMom[i - 1];
}
}
else
{
//.........这里部分代码省略.........
示例2: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
if (!stockSerie.HasVolume)
{
return;
}
FloatSerie fastMom = stockSerie.CalculateBuySellMomemtum((int)this.parameters[0], (bool)this.parameters[1]);
this.series[0] = fastMom;
this.series[0].Name = this.SerieNames[0];
FloatSerie slowMom = fastMom.CalculateEMA((int)this.parameters[0] / 2);
this.series[1] = slowMom;
this.series[1].Name = this.SerieNames[1];
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = 1; i < stockSerie.Count; i++)
{
this.eventSeries[0][i] = (slowMom[i - 1] > fastMom[i - 1] && slowMom[i] < fastMom[i]);
this.eventSeries[1][i] = (slowMom[i - 1] < fastMom[i - 1] && slowMom[i] > fastMom[i]);
}
}