本文整理汇总了C#中StockSerie.CalculateVarTrailStop方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.CalculateVarTrailStop方法的具体用法?C# StockSerie.CalculateVarTrailStop怎么用?C# StockSerie.CalculateVarTrailStop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSerie
的用法示例。
在下文中一共展示了StockSerie.CalculateVarTrailStop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
FloatSerie longStopSerie;
FloatSerie shortStopSerie;
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
float indicatorMax = (float)this.Parameters[2];
float indicatorCenter = (float)this.Parameters[3];
float indicatorWeight = (float)this.Parameters[4];
stockSerie.CalculateVarTrailStop((int)this.Parameters[0], ((string)this.Parameters[1]).Replace('_', ','), indicatorMax, indicatorCenter, indicatorWeight, out longStopSerie, out shortStopSerie);
this.Series[0] = longStopSerie;
this.Series[1] = shortStopSerie;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = (int)this.Parameters[0]; i < stockSerie.Count; i++)
{
this.Events[0][i] = !float.IsNaN(longStopSerie[i]);
this.Events[1][i] = !float.IsNaN(shortStopSerie[i]);
this.Events[2][i] = float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]);
this.Events[3][i] = float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]);
this.Events[4][i] = !float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]) && longStopSerie[i - 1] < longStopSerie[i];
this.Events[5][i] = !float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]) && shortStopSerie[i - 1] > shortStopSerie[i];
this.Events[6][i] = !float.IsNaN(longStopSerie[i]) && !float.IsNaN(longStopSerie[i - 1]) && lowSerie[i] > longStopSerie[i] && lowSerie[i - 1] <= longStopSerie[i - 1];
this.Events[7][i] = !float.IsNaN(shortStopSerie[i]) && !float.IsNaN(shortStopSerie[i - 1]) && highSerie[i] < shortStopSerie[i] && highSerie[i - 1] >= shortStopSerie[i - 1];
}
}