本文整理汇总了C#中StockSerie.GetTrailStop方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.GetTrailStop方法的具体用法?C# StockSerie.GetTrailStop怎么用?C# StockSerie.GetTrailStop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSerie
的用法示例。
在下文中一共展示了StockSerie.GetTrailStop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Initialise
public override void Initialise(StockSerie stockSerie, StockOrder lastBuyOrder, bool supportShortSelling)
{
base.Initialise(stockSerie, lastBuyOrder, supportShortSelling);
this.SRTrailStop = stockSerie.GetTrailStop(trailName);
this.adxDecorator = stockSerie.GetDecorator("DIV(1)", ((IStockIndicator)TriggerIndicator).Name);
}
示例3: GetViewableItem
public static IStockViewableSeries GetViewableItem(string fullString, StockSerie stockSerie)
{
IStockViewableSeries viewableSerie = null;
string[] fields = fullString.Split('|');
int offset = 2;
switch (fields[0].ToUpper())
{
case "INDICATOR":
if (stockSerie == null)
{
viewableSerie = StockIndicatorManager.CreateIndicator(fields[1]);
}
else
{
viewableSerie = stockSerie.GetIndicator(fields[1]);
}
offset = 2;
break;
case "PAINTBAR":
if (stockSerie == null)
{
viewableSerie = StockPaintBarManager.CreatePaintBar(fields[1]);
}
else
{
viewableSerie = stockSerie.GetPaintBar(fields[1]);
}
offset = 2;
break;
case "TRAILSTOP":
if (stockSerie == null)
{
viewableSerie = StockTrailStopManager.CreateTrailStop(fields[1]);
}
else
{
viewableSerie = stockSerie.GetTrailStop(fields[1]);
}
offset = 2;
break;
case "DECORATOR":
if (stockSerie == null)
{
viewableSerie = StockDecoratorManager.CreateDecorator(fields[1], fields[2]);
}
else
{
viewableSerie = stockSerie.GetDecorator(fields[1], fields[2]);
}
offset = 3;
break;
case "TRAIL":
if (stockSerie == null)
{
viewableSerie = StockTrailManager.CreateTrail(fields[1], fields[2]);
}
else
{
viewableSerie = stockSerie.GetTrail(fields[1], fields[2]);
}
offset = 3;
break;
default:
return null;
}
if (viewableSerie != null)
{
for (int i = 0; i < viewableSerie.SeriesCount; i++)
{
int index = 2 * i + offset;
if (index < fields.Length)
{
viewableSerie.SeriePens[i] = GraphCurveType.PenFromString(fields[index]);
viewableSerie.SerieVisibility[i] = bool.Parse(fields[index + 1]);
}
else
{
viewableSerie.SerieVisibility[i] = true;
}
}
if (fields[0].ToUpper() == "DECORATOR")
{
offset += viewableSerie.SeriesCount*2;
IStockDecorator decorator = viewableSerie as IStockDecorator;
for (int i = 0; i < decorator.EventCount; i++)
{
int index = 2 * i + offset;
if (index < fields.Length)
{
decorator.EventPens[i] = GraphCurveType.PenFromString(fields[index]);
decorator.EventVisibility[i] = bool.Parse(fields[index + 1]);
}
else
{
decorator.EventVisibility[i] = true;
}
}
}
}
//.........这里部分代码省略.........
示例4: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
Queue<float> resistanceQueue = new Queue<float>(new float[] { float.MinValue, float.MinValue });
Queue<float> supportQueue = new Queue<float>(new float[] { float.MaxValue, float.MaxValue });
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
int period = (int)this.Parameters[0];
IStockTrailStop trailStop = stockSerie.GetTrailStop("TRAILHL(" + period + ")");
FloatSerie longStopSerie = trailStop.Series[0];
FloatSerie shortStopSerie = trailStop.Series[1];
BoolSerie brokenUpSerie = trailStop.Events[2];
BoolSerie brokenDownSerie = trailStop.Events[3];
FloatSerie supportSerie = new FloatSerie(stockSerie.Count, "TRAILHL.S"); supportSerie.Reset(float.NaN);
FloatSerie resistanceSerie = new FloatSerie(stockSerie.Count, "TRAILHL.R"); resistanceSerie.Reset(float.NaN);
this.Series[0] = supportSerie;
this.Series[1] = resistanceSerie;
// Detecting events
this.CreateEventSeries(stockSerie.Count);
this.Events[0] = brokenUpSerie;
this.Events[1] = brokenDownSerie;
// Begin Sequence
// Calculate Support/Resistance
float extremum = lowSerie[0];
bool waitingForEndOfTrend = false;
int i = 0;
for (; i < stockSerie.Count && (!brokenUpSerie[i] && !brokenDownSerie[i]); i++)
{
//if (float.IsNaN(longStopSerie[i]))
//{
// this.UpDownState[i] = StockSerie.Trend.DownTrend; // Down trend
// supportSerie[i] = float.NaN;
// resistanceSerie[i] = highSerie.GetMax(0, i);
// resistanceQueue.Dequeue();
// resistanceQueue.Enqueue(resistanceSerie[i]);
// extremum = highSerie.GetMax(0, i);
//}
//else
//{
// this.UpDownState[i] = StockSerie.Trend.UpTrend; // Up trend
// supportSerie[i] = lowSerie.GetMin(0, i);
// supportQueue.Dequeue();
// supportQueue.Enqueue(supportSerie[i]);
// resistanceSerie[i] = float.NaN;
// extremum = lowSerie.GetMin(0, i);
//}
}
if (i < stockSerie.Count)
{
if (brokenUpSerie[i])
{
this.UpDownState[i] = StockSerie.Trend.UpTrend;
extremum = lowSerie.GetMin(0, i);
}
if (brokenDownSerie[i])
{
this.UpDownState[i] = StockSerie.Trend.DownTrend;
extremum = highSerie.GetMax(0, i);
}
}
for (; i < stockSerie.Count; i++)
{
bool upSwing = float.IsNaN(shortStopSerie[i]);
this.UpDownState[i] = StockUpDownIndicatorBase.BoolToTrend(upSwing);
this.Events[8][i] = upSwing;
this.Events[9][i] = !upSwing;
if (brokenUpSerie[i])
{
supportSerie[i] = extremum;
supportQueue.Dequeue();
supportQueue.Enqueue(extremum);
resistanceSerie[i] = float.NaN;
if (waitingForEndOfTrend)
{// Detect EndOfUptrend
waitingForEndOfTrend = false;
this.Events[3][i] = true;
}
else if (extremum > resistanceQueue.ElementAt(0))
{// Detect if pullback in uptrend
this.Events[2][i] = true;
waitingForEndOfTrend = true;
}
if (extremum > supportQueue.ElementAt(0))
{
// Higher Low detected
//.........这里部分代码省略.........
示例5: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
using (MethodLogger ml = new MethodLogger(this))
{
CreateEventSeries(stockSerie.Count);
IStockDecorator originalDecorator = stockSerie.GetDecorator(this.Name.Replace("WAIT", ""), this.DecoratedItem);
this.Series[0] = originalDecorator.Series[0];
this.Series[1] = originalDecorator.Series[1];
this.Series[2] = originalDecorator.Series[2];
IStockTrailStop trailIndicator = stockSerie.GetTrailStop("TRAILHL(1)");
FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
int exhaustionTopIndex =0;
int exhaustionBottomIndex = 1;
int bearishDivergenceIndex = 2;
int bullishDivergenceIndex = 3;
int upTrendIndex = 0;
bool waitExhaustionTop = false;
bool waitExhaustionBottom = false;
bool waitBearishDivergence = false;
bool waitBullishDivergence = false;
for (int i = 10; i < stockSerie.Count; i++)
{
if (waitExhaustionTop)
{
if (!trailIndicator.Events[upTrendIndex][i])// (highSerie[i - 1] > highSerie[i])
{
waitExhaustionTop = false;
this.eventSeries[exhaustionTopIndex][i] = true;
}
}
else
{
if (originalDecorator.Events[exhaustionTopIndex][i])
{
if (!trailIndicator.Events[upTrendIndex][i])// (highSerie[i - 1] > highSerie[i])
{
this.eventSeries[exhaustionTopIndex][i] = true;
}
else
{
waitExhaustionTop = true;
}
}
}
if (waitBearishDivergence)
{
if (!trailIndicator.Events[upTrendIndex][i])// (highSerie[i - 1] > highSerie[i])
{
waitBearishDivergence = false;
this.eventSeries[bearishDivergenceIndex][i] = true;
}
}
else
{
if (originalDecorator.Events[bearishDivergenceIndex][i])
{
if (!trailIndicator.Events[upTrendIndex][i])// (highSerie[i - 1] > highSerie[i])
{
this.eventSeries[bearishDivergenceIndex][i] = true;
}
else
{
waitBearishDivergence = true;
}
}
}
if (waitExhaustionBottom)
{
if (trailIndicator.Events[upTrendIndex][i]) // (lowSerie[i - 1] < lowSerie[i])
{
waitExhaustionBottom = false;
this.eventSeries[exhaustionBottomIndex][i] = true;
}
}
else
{
if (originalDecorator.Events[exhaustionBottomIndex][i])
{
if (trailIndicator.Events[upTrendIndex][i]) // (lowSerie[i - 1] < lowSerie[i])
{
this.eventSeries[exhaustionBottomIndex][i] = true;
}
else
{
waitExhaustionBottom = true;
}
}
}
if (waitBullishDivergence)
//.........这里部分代码省略.........
示例6: TrailHL
public bool TrailHL(int i, StockSerie stockSerie, ref string eventName)
{
eventName = "UpBreak_TRAILHL(4)";
BoolSerie upTrend = stockSerie.GetTrailStop("TRAILHL(1)").Events[0];
BoolSerie upBar = stockSerie.GetPaintBar("HIGHLOWDAYS(6)").Events[0];
FloatSerie roc = stockSerie.GetIndicator("ROCEX3(200,100,50,10,20)").Series[0];
return upTrend[i] && roc[i] > 0 && (upBar[i] && !upBar[i - 1]);
}
示例7: TrailBB
public bool TrailBB(int i, StockSerie stockSerie, ref string eventName)
{
eventName = "UpBreak_TRAILBB(6,2,-2)";
BoolSerie upTrend = stockSerie.GetTrailStop("TRAILBB(6,2,-2)").Events[0];
return !upTrend[i - 1] && upTrend[i];
}
示例8: 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]);
}
示例9: ApplyTo
public override void ApplyTo(StockSerie stockSerie)
{
int period = (int)this.parameters[0];
int smoothing = (int)this.parameters[1];
IStockTrailStop trail = stockSerie.GetTrailStop("TRAILHLS(" + period + "," + smoothing + ")");
FloatSerie longStop = trail.Series[0];
FloatSerie shortStop = trail.Series[1];
FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE).CalculateEMA(smoothing);
FloatSerie distSerie = new FloatSerie(stockSerie.Count);
for (int i = period + smoothing; i < stockSerie.Count; i++)
{
distSerie[i] = float.IsNaN(longStop[i]) ? closeSerie[i] - shortStop[i] : closeSerie[i] - longStop[i];
}
//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;
}