本文整理汇总了C#中StockSerie.CalculateSAR方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.CalculateSAR方法的具体用法?C# StockSerie.CalculateSAR怎么用?C# StockSerie.CalculateSAR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSerie
的用法示例。
在下文中一共展示了StockSerie.CalculateSAR方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
float accelerationFactorStart = (float)this.parameters[0];
float accelerationFactorStep = (float)this.parameters[1];
float accelerationFactorMax = (float)this.parameters[2];
FloatSerie sarSupport;
FloatSerie sarResistance;
stockSerie.CalculateSAR(accelerationFactorStep, accelerationFactorStart, accelerationFactorMax, out sarSupport,
out sarResistance, (int)this.parameters[3]);
this.Series[0] = sarSupport;
this.Series[1] = sarResistance;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
float previousHigh = stockSerie.Values.First().HIGH, previousLow = stockSerie.Values.First().LOW;
float previousHigh2 = stockSerie.Values.First().HIGH, previousLow2 = stockSerie.Values.First().LOW;
bool waitingForEndTrend = false;
for (int i = 5; i < stockSerie.Count; i++)
{
if (float.IsNaN(sarResistance[i]) && !float.IsNaN(sarResistance[i - 1]))
{
this.Events[0][i] = true; // SupportDetected
if (waitingForEndTrend)
{
this.Events[3][i] = true; // EndOfTrend
waitingForEndTrend = false;
}
if (sarSupport[i] > previousLow)
{
this.Events[4][i] = true; // HigherLow
if (sarSupport[i] > previousHigh2)
{
this.Events[2][i] = true; // PB
waitingForEndTrend = true;
}
}
previousLow2 = previousLow;
previousLow = sarSupport[i];
}
if (float.IsNaN(sarSupport[i]) && !float.IsNaN(sarSupport[i - 1]))
{
this.Events[1][i] = true; // ResistanceDetected
if (waitingForEndTrend)
{
this.Events[3][i] = true; // EndOfTrend
waitingForEndTrend = false;
}
if (sarResistance[i] < previousHigh)
{
this.Events[5][i] = true; // LowerHigh
if (sarResistance[i] < previousLow2)
{
this.Events[2][i] = true; // PB
waitingForEndTrend = true;
}
}
previousHigh2 = previousHigh;
previousHigh = sarResistance[i];
}
this.Events[6][i] = false;
this.Events[7][i] = false;
this.Events[8][i] = float.IsNaN(sarResistance[i]);
this.Events[9][i] = float.IsNaN(sarSupport[i]);
}
}
示例2: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
float accelerationFactorStep = (float)this.parameters[0];
float accelerationFactorMax = (float)this.parameters[1];
FloatSerie sarSupport1;
FloatSerie sarResistance1;
FloatSerie sarSupport2;
FloatSerie sarResistance2;
float ratio = (float)this.parameters[2];
stockSerie.CalculateSAR(accelerationFactorStep, accelerationFactorStep, accelerationFactorMax, out sarSupport1, out sarResistance1, 1);
stockSerie.CalculateSAR2(accelerationFactorStep / ratio, accelerationFactorStep / ratio, accelerationFactorMax / ratio, sarSupport1, sarResistance1, out sarSupport2, out sarResistance2);
this.Series[0] = sarSupport1;
this.Series[1] = sarResistance1;
this.Series[2] = sarSupport2;
this.Series[3] = sarResistance2;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = 5; i < stockSerie.Count; i++)
{
this.Events[0][i] = float.IsNaN(sarResistance1[i - 1]) && !float.IsNaN(sarResistance1[i]);
this.Events[1][i] = float.IsNaN(sarSupport1[i - 1]) && !float.IsNaN(sarSupport1[i]);
this.Events[2][i] = float.IsNaN(sarResistance2[i - 1]) && !float.IsNaN(sarResistance2[i]);
this.Events[3][i] = float.IsNaN(sarSupport2[i - 1]) && !float.IsNaN(sarSupport2[i]);
}
}