// Cycle Counter Vars #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { pitColor = PitColor(Color.Black, 80000, 25, 161500); Add(pitColor); stoc = Stochastics(stocD, stocK, stocS); Add(stoc); stoc.Plots[0].Pen.Color = Color.Blue; // D color stoc.Plots[1].Pen.Color = Color.Black; // K color stoc.Plots[0].Pen.Width = 2; // D color stoc.Plots[1].Pen.Width = 1; // K color stoc.Lines[0].Pen.Color = Color.Black; // Lower stoc.Lines[1].Pen.Color = Color.Black; // Upper stoc.Lines[0].Pen.DashStyle = DashStyle.Dot; // Lower stoc.Lines[1].Pen.DashStyle = DashStyle.Dot; // Upper stoc.Lines[0].Pen.Width = 2; // Lower stoc.Lines[1].Pen.Width = 2; // Upper stoc.Lines[0].Value = 20; // Lower stoc.Lines[1].Value = 80; // Upper constantLines = ConstantLines(45, 55, 0, 0); constantLines.Panel = 1; // specifying to use the first indicator's panel Add(constantLines); constantLines.Plots[0].Pen.Color = Color.Red; constantLines.Plots[1].Pen.Color = Color.Red; CalculateOnBarClose = true; }
/// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { pitColor = PitColor(Color.Black, 80000, 25, 161500); Add(pitColor); ema = EMA(EmaPeriod); Add(ema); ema.Plots[0].Pen.Color = Color.Gray; sma = SMARick(SmaPeriod); Add(sma); //sma.Plots[0].Pen.Color = Color.Red; stoc = Stochastics(stocD, stocK, stocS); Add(stoc); stoc.Plots[0].Pen.Color = Color.Blue; // D color stoc.Plots[1].Pen.Color = Color.Black; // K color stoc.Plots[0].Pen.Width = 2; // D color stoc.Plots[1].Pen.Width = 1; // K color stoc.Lines[0].Pen.Color = Color.Black; // Lower stoc.Lines[1].Pen.Color = Color.Black; // Upper stoc.Lines[0].Pen.DashStyle = DashStyle.Dot; // Lower stoc.Lines[1].Pen.DashStyle = DashStyle.Dot; // Upper stoc.Lines[0].Pen.Width = 2; // Lower stoc.Lines[1].Pen.Width = 2; // Upper stoc.Lines[0].Value = 20; // Lower stoc.Lines[1].Value = 80; // Upper constantLines = ConstantLines(45, 55, 0, 0); constantLines.Panel = 1; // specifying to use the first indicator's panel Add(constantLines); constantLines.Plots[0].Pen.Color = Color.Red; constantLines.Plots[1].Pen.Color = Color.Red; macd = MACD(macdFast, macdSlow, macdSmooth); Add(macd); macd.CalculateOnBarClose = true; macd.Plots[0].Pen.Color = Color.Black; // Macd macd.Plots[1].Pen.Color = Color.Blue; // Avg macd.Plots[2].Pen.Color = Color.Transparent; //downBar //macd.Plots[3].Pen.Color = Color.Transparent; // Diff macd.Plots[0].Pen.Width = 2; macd.Plots[1].Pen.Width = 3; macd.Plots[0].PlotStyle = PlotStyle.Bar; SetProfitTarget("", CalculationMode.Ticks, ProfitTarget); SetStopLoss("", CalculationMode.Ticks, StopLoss, false); SetTrailStop("", CalculationMode.Ticks, TrailingStop, false); CalculateOnBarClose = true; }
void chart_BoundDataChanged(object sender, RoutedEventArgs e) { XYDiagram2D diagram = (XYDiagram2D)chart.Diagram; if (diagram.Series[0].Points.Count == 0) { return; } double minPrice = Double.MaxValue; double maxPrice = 0; double averagePrice = 0; foreach (SeriesPoint point in diagram.Series[0].Points) { double price = point.Value; if (price < minPrice) { minPrice = price; } if (price > maxPrice) { maxPrice = price; } averagePrice += price; } averagePrice /= diagram.Series[0].Points.Count; ConstantLine minConstantLine = new ConstantLine(minPrice, "Min"); minConstantLine.Brush = new SolidColorBrush(Colors.Green); minConstantLine.Title.Foreground = new SolidColorBrush(Colors.Green); ConstantLine maxConstantLine = new ConstantLine(maxPrice, "Max"); maxConstantLine.Brush = new SolidColorBrush(Colors.Red); maxConstantLine.Title.Foreground = new SolidColorBrush(Colors.Red); ConstantLine averageConstantLine = new ConstantLine(averagePrice, "Average"); averageConstantLine.Brush = new SolidColorBrush(Color.FromArgb(0xFF, 0x9A, 0xCD, 0x32)); averageConstantLine.Title.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x9A, 0xCD, 0x32)); ConstantLines.AddRange(new ConstantLine[] { minConstantLine, maxConstantLine, averageConstantLine }); foreach (ConstantLine constantLine in ConstantLines) { constantLine.Title.Alignment = ConstantLineTitleAlignment.Far; } }