本文整理汇总了C#中StockSerie.GetIndicator方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.GetIndicator方法的具体用法?C# StockSerie.GetIndicator怎么用?C# StockSerie.GetIndicator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSerie
的用法示例。
在下文中一共展示了StockSerie.GetIndicator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
FloatSerie lowEMASerie = stockSerie.GetIndicator(this.SerieNames[0]).Series[0];
FloatSerie highEMASerie = stockSerie.GetIndicator(this.SerieNames[1]).Series[0];
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
this.Series[0] = lowEMASerie;
this.Series[1] = highEMASerie;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = (int)this.parameters[0]; i < stockSerie.Count; i++)
{
if (lowSerie[i] > highEMASerie[i])
{
this.Events[0][i] = true;
if (!this.Events[0][i-1])
this.Events[2][i] = true;
}
else if (highSerie[i] < lowEMASerie[i])
{
this.Events[1][i] = true;
if (!this.Events[1][i - 1])
this.Events[3][i] = true;
}
else
{
this.Events[4][i] = true;
}
}
}
示例2: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
// Calculate Bands
int period = (int)this.parameters[0];
FloatSerie ema = stockSerie.GetIndicator("EMA(" + period + ")").Series[0];
FloatSerie atr = stockSerie.GetIndicator("ATR(" + period + ")").Series[0];
float upCoef = (float)this.parameters[1];
float downCoef = (float)this.parameters[2];
FloatSerie upperKeltnerBand = ema + atr * upCoef;
this.series[0] = upperKeltnerBand;
this.Series[0].Name = this.SerieNames[0];
FloatSerie lowerKeltnerBand = ema + atr * downCoef;
this.series[1] = lowerKeltnerBand;
this.Series[1].Name = this.SerieNames[1];
// Detecting events
this.CreateEventSeries(stockSerie.Count);
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
for (int i = 1; i < upperKeltnerBand.Count; i++)
{
this.eventSeries[0][i] = closeSerie[i] > upperKeltnerBand[i];
this.eventSeries[1][i] = closeSerie[i] < lowerKeltnerBand[i];
this.eventSeries[2][i] = closeSerie[i] >= lowerKeltnerBand[i] && closeSerie[i] <= upperKeltnerBand[i];
}
}
示例3: CreateInitialisedFrom
public static IStockViewableSeries CreateInitialisedFrom(IStockViewableSeries aViewableSerie, StockSerie stockSerie)
{
if (!stockSerie.Initialise()) return null;
IStockViewableSeries viewableSerie = null;
switch (aViewableSerie.Type)
{
case ViewableItemType.Indicator:
viewableSerie = stockSerie.GetIndicator(aViewableSerie.Name);
break;
case ViewableItemType.Decorator:
viewableSerie = stockSerie.GetDecorator(aViewableSerie.Name, ((IStockDecorator)aViewableSerie).DecoratedItem);
break;
case ViewableItemType.PaintBar:
viewableSerie = stockSerie.GetPaintBar(aViewableSerie.Name);
break;
case ViewableItemType.TrailStop:
viewableSerie = stockSerie.GetTrailStop(aViewableSerie.Name);
break;
case ViewableItemType.Trail:
viewableSerie = stockSerie.GetTrail(aViewableSerie.Name, ((IStockTrail)aViewableSerie).TrailedItem);
break;
default:
break;
}
return viewableSerie;
}
示例4: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
FloatSerie fastSerie = stockSerie.GetIndicator(this.SerieNames[0]).Series[0].ShiftForward((int)this.parameters[3]);
FloatSerie mediumSerie = stockSerie.GetIndicator(this.SerieNames[1]).Series[0].ShiftForward((int)this.parameters[4]);
FloatSerie slowSerie = stockSerie.GetIndicator(this.SerieNames[2]).Series[0].ShiftForward((int)this.parameters[5]);
this.Series[0] = fastSerie;
this.Series[1] = mediumSerie;
this.Series[2] = slowSerie;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = 2; i < stockSerie.Count; i++)
{
if (fastSerie[i] > mediumSerie[i] && mediumSerie[i] > slowSerie[i])
{
this.Events[0][i] = true;
}
else if (fastSerie[i] < mediumSerie[i] && mediumSerie[i] < slowSerie[i])
{
this.Events[1][i] = true;
}
}
}
示例5: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
FloatSerie indicatorSerie = stockSerie.GetIndicator(this.parameters[0].ToString()).Series[0];
FloatSerie speedSerie = indicatorSerie - indicatorSerie.CalculateEMA((int) this.parameters[1]);
this.series[0] = speedSerie;
this.Series[0].Name = this.Name;
}
示例6: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
int period = (int)this.parameters[0];
int smoothing = (int)this.parameters[1];
IStockIndicator donchianIndicator = stockSerie.GetIndicator("DONCHIAN(" + period + ")");
// Calculate Donchian Channel
FloatSerie upLine = donchianIndicator.Series[0];
FloatSerie downLine = donchianIndicator.Series[4];
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
this.series[0] = ((upLine - downLine) / (closeSerie * 0.01f)).CalculateEMA(smoothing);
this.Series[0].Name = this.SerieNames[0];
// Detecting events
this.CreateEventSeries(stockSerie.Count);
}
示例7: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
int period = (int)this.parameters[0];
IStockIndicator momentum = stockSerie.GetIndicator("MOMENTUM(" + period + ",1,10)");
FloatSerie momentumSerie = momentum.Series[0];
FloatSerie atrSerie = stockSerie.GetSerie(StockDataType.ATR);
FloatSerie distSerie = momentumSerie.Div(atrSerie.Cumul(period));
//cciSerie = cciSerie.CalculateSigmoid(100f, 0.02f).CalculateEMA((int)Math.Sqrt();
//FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
//for (int i = 10; i < cciSerie.Count; i++)
//{
// if (cciSerie[i] > overbought && cciSerie[i] <= cciSerie[i - 1] && closeSerie[i] >= closeSerie[i-1])
// {
// cciSerie[i] = cciSerie[i - 1] + (100 - cciSerie[i - 1]) / 4f;
// }
// else if (cciSerie[i] < oversold && cciSerie[i] >= cciSerie[i - 1] && closeSerie[i] <= closeSerie[i-1])
// {
// cciSerie[i] = cciSerie[i - 1] *0.75f;
// }
//}
this.series[0] = distSerie;
this.series[0].Name = this.Name;
}
示例8: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
// Calculate Bollinger Bands
FloatSerie upperBB = null;
FloatSerie lowerBB = null;
FloatSerie ema = stockSerie.GetIndicator(this.parameters[1] + "(" + (int)this.parameters[0] + ")").Series[0];
stockSerie.GetSerie(StockDataType.CLOSE).CalculateBB(ema, (int)this.parameters[0], 1f, -1f, ref upperBB, ref lowerBB);
FloatSerie widthLog = ((upperBB - lowerBB)/ema)*20.0f;
for (int i = (int) this.parameters[0]; i < stockSerie.Count; i++)
{
widthLog[i] = (float)Math.Log10(widthLog[i]);
}
this.series[0] = widthLog;
this.Series[0].Name = this.SerieNames[0];
// Detecting events
this.CreateEventSeries(stockSerie.Count);
}
示例9: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
// Detecting events
this.CreateEventSeries(stockSerie.Count);
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
FloatSerie atr1Serie = stockSerie.GetIndicator("ATR(1)").Series[0];
FloatSerie atr20Serie = stockSerie.GetIndicator("ATR(20)").Series[0];
for (int i = 1; i < stockSerie.Count; i++)
{
// Check Gaps
this.eventSeries[0][i] = highSerie[i - 1] < lowSerie[i];
this.eventSeries[1][i] = lowSerie[i - 1] > highSerie[i];
this.eventSeries[2][i] = atr1Serie[i] > 1.5*atr20Serie[i];
}
}
示例10: EMAUp
public bool EMAUp(int i, StockSerie stockSerie)
{
FloatSerie ema6 = stockSerie.GetIndicator("EMA(6)").Series[0];
FloatSerie ema12 = stockSerie.GetIndicator("EMA(12)").Series[0];
FloatSerie ema50 = stockSerie.GetIndicator("EMA(50)").Series[0];
FloatSerie longStop = stockSerie.GetTrailStop("TRAILHL(3)").Series[0];
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
return (!float.IsNaN(longStop[i - 1]) && !float.IsNaN(longStop[i]) && closeSerie[i] < ema50[i]);
}
示例11: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
FloatSerie fastSerie = stockSerie.GetIndicator(this.SerieNames[0]).Series[0];
FloatSerie slowSerie = stockSerie.GetIndicator(this.SerieNames[1]).Series[0];
FloatSerie closeSerie = (stockSerie.GetSerie(StockDataType.CLOSE) + stockSerie.GetSerie(StockDataType.HIGH) + stockSerie.GetSerie(StockDataType.LOW)) / 3.0f;
this.Series[0] = fastSerie;
this.Series[1] = slowSerie;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = 2; i < stockSerie.Count; i++)
{
if (fastSerie[i] > slowSerie[i])
{
if (closeSerie[i] > fastSerie[i])
{
this.Events[2][i] = true;
}
else
{
this.Events[4][i] = true;
}
if (fastSerie[i - 1] < slowSerie[i - 1])
{
this.Events[0][i] = true;
}
}
else
{
if (closeSerie[i] < fastSerie[i])
{
this.Events[3][i] = true;
}
else
{
this.Events[5][i] = true;
}
if (fastSerie[i - 1] > slowSerie[i - 1])
{
this.Events[1][i] = true;
}
}
}
}
示例12: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
FloatSerie trail1Serie = new FloatSerie(stockSerie.Count);
//FloatSerie trail2Serie = new FloatSerie(stockSerie.Count);
//FloatSerie trail3Serie = new FloatSerie(stockSerie.Count);
int period = (int)this.parameters[0];
BoolSerie event1 = stockSerie.GetIndicator("TRAILHLSR(" + period + ")").Events[8];
BoolSerie event2 = stockSerie.GetIndicator("TRAILHLSR(" + period * 3 + ")").Events[8];
BoolSerie event3 = stockSerie.GetIndicator("TRAILHLSR(" + period * 9 + ")").Events[8];
BoolSerie event4 = stockSerie.GetIndicator("TRAILHLSR(" + period * 27 + ")").Events[8];
for (int i = period * 9; i < stockSerie.Count; i++)
{
trail1Serie[i] = (event1[i] ? 1f : -1f) + (event2[i] ? 2f : -2f) + (event3[i] ? 3f : -3f) + (event4[i] ? 4f : -4f);
//trail2Serie[i] = event2[i] ? 2f : -2f;
//trail3Serie[i] = event3[i] ? 3f : -3f;
}
this.series[0] = trail1Serie;
//this.series[1] = trail2Serie;
//this.series[2] = trail3Serie;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = 10; i < stockSerie.Count; i++)
{
this.eventSeries[0][i] = event1[i] && event2[i] && event3[i];
this.eventSeries[1][i] = !(event1[i] || event2[i] || event3[i]);
this.eventSeries[2][i] = this.eventSeries[0][i] && !this.eventSeries[0][i - 1];
this.eventSeries[3][i] = this.eventSeries[1][i] && !this.eventSeries[1][i - 1];
}
}
示例13: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
int period = (int)this.parameters[0];
FloatSerie stdevSerie = stockSerie.GetSerie(StockDataType.CLOSE).CalculateStdev(period);
FloatSerie emaSerie = stockSerie.GetIndicator("EMA(" + period + ")").Series[0];
FloatSerie stdevCount = new FloatSerie(emaSerie.Count, this.SerieNames[0]);
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
for (int i = period; i < emaSerie.Count; i++)
{
if (stdevSerie[i] >= -0.00001f && stdevSerie[i] <= 0.00001f)
{
stdevCount[i] = 0;
}
else
{
stdevCount[i] = (closeSerie[i] - emaSerie[i]) / stdevSerie[i];
}
}
this.Series[0] = stdevCount;
}
示例14: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
using (MethodLogger ml = new MethodLogger(this))
{
List<string> eventNames = this.EventNames.ToList();
int ExhaustionTopIndex = eventNames.IndexOf("ExhaustionTop");
int ExhaustionBottomIndex = eventNames.IndexOf("ExhaustionBottom");
int BearishDivergenceIndex = eventNames.IndexOf("BearishDivergence");
int BullishDivergenceIndex = eventNames.IndexOf("BullishDivergence");
int ExhaustionTopOccuredIndex = eventNames.IndexOf("ExhaustionTopOccured");
int ExhaustionBottomOccuredIndex = eventNames.IndexOf("ExhaustionBottomOccured");
int PositiveIndex = eventNames.IndexOf("Positive");
int NegativeIndex = eventNames.IndexOf("Negative");
int BullishIndex = eventNames.IndexOf("Bullish");
int BearishIndex = eventNames.IndexOf("Bearish");
int BearFailureIndex = eventNames.IndexOf("BearFailure");
int BullFailureIndex = eventNames.IndexOf("BullFailure");
CreateEventSeries(stockSerie.Count);
int smoothing = (int)this.parameters[0];
float overbought = (float)this.parameters[1];
float oversold = (float)this.parameters[2];
int lookbackPeriod = (int)this.parameters[3];
int signalSmoothing = (int)this.parameters[4];
int countNegative = 0;
int countPositive = 0;
IStockIndicator indicator = stockSerie.GetIndicator(this.DecoratedItem);
if (indicator != null && indicator.Series[0].Count > 0)
{
FloatSerie indicatorToDecorate = indicator.Series[0].CalculateEMA(smoothing);
FloatSerie signalSerie = indicatorToDecorate.CalculateEMA(signalSmoothing);
FloatSerie upperLimit = new FloatSerie(indicatorToDecorate.Count); upperLimit.Reset(overbought);
FloatSerie lowerLimit = new FloatSerie(indicatorToDecorate.Count); lowerLimit.Reset(oversold);
if (smoothing <= 1) { this.SerieVisibility[0] = false; }
if (signalSmoothing <= 1) { this.SerieVisibility[3] = false; }
this.Series[0] = indicatorToDecorate;
this.Series[0].Name = this.SerieNames[0];
this.Series[1] = upperLimit;
this.Series[1].Name = this.SerieNames[1];
this.Series[2] = lowerLimit;
this.Series[2].Name = this.SerieNames[2];
this.Series[3] = signalSerie;
this.Series[3].Name = this.SerieNames[3];
if (indicator.DisplayTarget == IndicatorDisplayTarget.RangedIndicator && indicator is IRange)
{
IRange range = (IRange)indicator;
indicatorToDecorate = indicatorToDecorate.Sub((range.Max + range.Min) / 2.0f);
}
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
int lastExhaustionSellIndex = int.MinValue;
int lastExhaustionBuyIndex = int.MinValue;
float exhaustionBuyPrice = highSerie[0];
float exhaustionSellPrice = lowSerie[0];
float previousValue = indicatorToDecorate[0];
float currentValue;
int i = 0;
for (i = 1; i < indicatorToDecorate.Count - 1; i++)
{
if (indicatorToDecorate[i] > 0)
{
this.Events[PositiveIndex][i] = true;
countPositive++;
countNegative = 0;
}
else
{
this.Events[NegativeIndex][i] = true;
countPositive = 0;
countNegative++;
}
if (indicatorToDecorate[i] > signalSerie[i])
{
this.Events[BullishIndex][i] = true;
}
else
{
this.Events[BearishIndex][i] = true;
}
currentValue = indicatorToDecorate[i];
if (currentValue == previousValue)
{
if (indicatorToDecorate.IsBottomIsh(i))
{
if (currentValue <= oversold)
{
// This is an exhaustion selling
this.Events[ExhaustionBottomIndex][i + 1] = true;
exhaustionSellPrice = lowSerie[i];
lastExhaustionSellIndex = i + 1;
}
else
//.........这里部分代码省略.........
示例15: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
IStockIndicator fastSerie = stockSerie.GetIndicator("EMA(" + this.parameters[0] + ")");
IStockIndicator slowSerie = stockSerie.GetIndicator("EMA(" + this.parameters[1] + ")");
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
FloatSerie POSCSerie = fastSerie.Series[0].Sub(slowSerie.Series[0]) / closeSerie;
this.series[0] = POSCSerie;
this.Series[0].Name = this.Name;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
for (int i = 2; i < stockSerie.Count; i++)
{
this.eventSeries[0][i] = (POSCSerie[i - 2] < POSCSerie[i - 1] && POSCSerie[i - 1] > POSCSerie[i]);
this.eventSeries[1][i] = (POSCSerie[i - 2] > POSCSerie[i - 1] && POSCSerie[i - 1] < POSCSerie[i]);
this.eventSeries[2][i] = (POSCSerie[i - 1] < 0 && POSCSerie[i] >= 0);
this.eventSeries[3][i] = (POSCSerie[i - 1] > 0 && POSCSerie[i] <= 0);
}
}