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); } }