private IndicatorBase CreateMAIndicator(string indicatorType) { IndicatorBase indicator; if (indicatorType.StartsWith("MA (")) { indicator = new MovingAverageIndicator(); indicator.Name = "MA"; } else if (indicatorType.StartsWith("Exponential MA")) { indicator = new ExponentialMovingAverageIndicator(); indicator.Name = "EMA"; } else if (indicatorType.StartsWith("Modified MA")) { indicator = new ModifiedMovingAverageIndicator(); indicator.Name = "MMA"; } else if (indicatorType.StartsWith("Modified Exponential MA")) { indicator = new ModifiedExponentialMovingAverageIndicator(); indicator.Name = "MEMA"; } else if (indicatorType.StartsWith("Weighted MA")) { indicator = new WeightedMovingAverageIndicator(); indicator.Name = "WMA"; } else if (indicatorType.StartsWith("Adaptive MA")) { indicator = new AdaptiveMovingAverageKaufmanIndicator(); indicator.Name = "KAMA"; ((AdaptiveMovingAverageKaufmanIndicator)indicator).SlowPeriod = 10; ((AdaptiveMovingAverageKaufmanIndicator)indicator).FastPeriod = 4; } else { indicator = new BollingerBandsIndicator(); indicator.Name = "BOLL"; ((BollingerBandsIndicator)indicator).StandardDeviations = 2; } ((ValuePeriodIndicatorBase)indicator).Period = 5; indicator.CategoryMember = "Date"; indicator.ValueMember = "Close"; indicator.DataSource = viewModel.Data; return(indicator); }
private IndicatorBase CreateTrendline(Trendlines trendlineToAdd) { switch (trendlineToAdd) { case Trendlines.MovingAverageIndicator: var maIndicator = new MovingAverageIndicator(); maIndicator.SetBinding(CommodityChannelIndexIndicator.ItemsSourceProperty, new Binding("SeriesData")); maIndicator.CategoryBinding = new PropertyNameDataPointBinding("DateCategory"); maIndicator.ValueBinding = new PropertyNameDataPointBinding("Close"); maIndicator.Period = 12; maIndicator.Stroke = Color.Orange; maIndicator.StrokeThickness = 1; return(maIndicator); case Trendlines.AdaptiveMovingAverageKaufmanIndicator: var amakIndicator = new AdaptiveMovingAverageKaufmanIndicator(); amakIndicator.SetBinding(CommodityChannelIndexIndicator.ItemsSourceProperty, new Binding("SeriesData")); amakIndicator.CategoryBinding = new PropertyNameDataPointBinding("DateCategory"); amakIndicator.ValueBinding = new PropertyNameDataPointBinding("Close"); amakIndicator.Period = 10; amakIndicator.SlowPeriod = 30; amakIndicator.FastPeriod = 2; amakIndicator.Stroke = Color.Orange; amakIndicator.StrokeThickness = 1; return(amakIndicator); case Trendlines.ExponentialMovingAverageIndicator: var emaIndicator = new ExponentialMovingAverageIndicator(); emaIndicator.SetBinding(CommodityChannelIndexIndicator.ItemsSourceProperty, new Binding("SeriesData")); emaIndicator.CategoryBinding = new PropertyNameDataPointBinding("DateCategory"); emaIndicator.ValueBinding = new PropertyNameDataPointBinding("Close"); emaIndicator.Period = 8; emaIndicator.Stroke = Color.Orange; emaIndicator.StrokeThickness = 1; return(emaIndicator); case Trendlines.BollingerBandsIndicator: var bbIndicator = new BollingerBandsIndicator(); bbIndicator.SetBinding(CommodityChannelIndexIndicator.ItemsSourceProperty, new Binding("SeriesData")); bbIndicator.CategoryBinding = new PropertyNameDataPointBinding("DateCategory"); bbIndicator.ValueBinding = new PropertyNameDataPointBinding("Close"); bbIndicator.Period = 5; bbIndicator.Stroke = Color.Orange; bbIndicator.LowerBandStroke = Color.Orange; bbIndicator.StandardDeviations = 3; bbIndicator.StrokeThickness = 1; return(bbIndicator); case Trendlines.WeightedMovingAverageIndicator: var wmaIndicator = new WeightedMovingAverageIndicator(); wmaIndicator.SetBinding(CommodityChannelIndexIndicator.ItemsSourceProperty, new Binding("SeriesData")); wmaIndicator.CategoryBinding = new PropertyNameDataPointBinding("DateCategory"); wmaIndicator.ValueBinding = new PropertyNameDataPointBinding("Close"); wmaIndicator.Period = 12; wmaIndicator.Stroke = Color.Orange; wmaIndicator.StrokeThickness = 1; return(wmaIndicator); default: return(null); } }