Beispiel #1
0
        public void ValueNewValue()
        {
            Chart chart = new Chart();

            chart.Width  = 400;
            chart.Height = 300;


            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = TrendLineToTest;

            chart.TrendLines.Add(trendLine);

            _isLoaded     = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();

            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                trendLine.Orientation = Orientation.Vertical;
                trendLine.Value       = 2;
                Assert.AreEqual(2, trendLine.Value);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
 string CreateLabel(TrendLine tl)
 {
     if( tl.FitType == FitType.Polynom || tl.FitType == FitType.Fourier)
     return string.Format("{0} {1}", tl.FitType, tl.Order);
       else
     return string.Format("{0}", tl.FitType);
 }
Beispiel #3
0
        public void LineColorNewValue()
        {
            Chart chart = new Chart();

            chart.Width  = 400;
            chart.Height = 300;


            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = TrendLineToTest;

            chart.TrendLines.Add(trendLine);

            _isLoaded     = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();

            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                trendLine.LineColor = new SolidColorBrush(Colors.Cyan);
                Common.AssertBrushesAreEqual(new SolidColorBrush(Colors.Cyan), trendLine.LineColor);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
        private void miTrend2_Click(object sender, System.EventArgs e)
        {
            CheckGroup(new MenuItem[] { miTrend2, miTrend3, miTrend4, miTrend5, miTrend6 }, sender);
            ChartData cd = trendChart.ChartGroups[0].ChartData;
            TrendLine tl = cd.TrendsList[0];

            if (miTrend2.Equals(sender))
            {
                tl.RegressionOptions.NumTerms = 2;
            }
            else if (miTrend3.Equals(sender))
            {
                tl.RegressionOptions.NumTerms = 3;
            }
            else if (miTrend4.Equals(sender))
            {
                tl.RegressionOptions.NumTerms = 4;
            }
            else if (miTrend5.Equals(sender))
            {
                tl.RegressionOptions.NumTerms = 5;
            }
            else if (miTrend6.Equals(sender))
            {
                tl.RegressionOptions.NumTerms = 6;
            }

            CalculateErrors();
        }
Beispiel #5
0
        public void ShadowEnabledNewValue()
        {
            Chart chart = new Chart();

            chart.Width  = 400;
            chart.Height = 300;


            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = TrendLineToTest;

            chart.TrendLines.Add(trendLine);

            _isLoaded     = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();

            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                trendLine.ShadowEnabled = true;
                Assert.IsTrue(trendLine.ShadowEnabled);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Beispiel #6
0
        public void AxisTypeDefaultValue()
        {
            Chart chart = new Chart();

            chart.Width  = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = TrendLineToTest;

            chart.TrendLines.Add(trendLine);

            _isLoaded     = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();

            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(AxisTypes.Primary, trendLine.AxisType);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
        private void OnLoad(object sender, EventArgs e)
        {
            dataService = DataService.GetService();

            var data = dataService.GetSymbolData("box");

            minX = data.Min(p => p.Date);
            maxX = data.Max(p => p.Date);

            financialChart1.BeginUpdate();
            financialChart1.BindingX = "date";
            financialChart1.Binding  = "close";
            financialChart1.Series.Add(new FinancialSeries()
            {
                Name = "Box"
            });
            financialChart1.ChartType = C1.Chart.Finance.FinancialChartType.Line;

            trendLine = new TrendLine()
            {
                Name = "Trend line"
            };
            financialChart1.Series.Add(trendLine);
            financialChart1.ToolTip.Content = "{seriesName}\nY: {y:0.00}";
            financialChart1.DataSource      = data;

            financialChart1.EndUpdate();

            fitType.DataSource = new FitType[] { FitType.Linear, FitType.Exponent, FitType.Polynom,
                                                 FitType.AverageX, FitType.MinX, FitType.MaxX, FitType.AverageY, FitType.MinY, FitType.MaxY };
        }
Beispiel #8
0
        protected override void Init()
        {	nu=false; nd=false; md=0; mu=0;
			InitFile();
		    if(_ftoInd==null) _ftoInd   = GetIndicator<FisherTransformOscillator>(Instrument.Id, Timeframe); 
			// Рисуем зоны
			if(toolTrendLine4==null) { toolTrendLine4 = Tools.Create<TrendLine>(); toolTrendLine4.Color=Color.HotPink;toolTrendLine4.Width=3; }
			if(toolTrendLine2==null) { toolTrendLine2 = Tools.Create<TrendLine>(); toolTrendLine2.Color=Color.Crimson;toolTrendLine2.Width=6; }
			if(toolTrendLineD==null) { toolTrendLineD = Tools.Create<TrendLine>(); toolTrendLineD.Color=Color.ForestGreen;toolTrendLineD.Width=6; }
			// Рисуем линии волн
			if(toolTrendLineU1==null) { toolTrendLineU1 = Tools.Create<TrendLine>(); toolTrendLineU1.Color=Color.Aqua;toolTrendLineU1.Width=3; }
			if(toolTrendLineU2==null) { toolTrendLineU2 = Tools.Create<TrendLine>(); toolTrendLineU2.Color=Color.Aqua;toolTrendLineU2.Width=3; }
			if(toolTrendLineU3==null) { toolTrendLineU3 = Tools.Create<TrendLine>(); toolTrendLineU3.Color=Color.Aqua;toolTrendLineU3.Width=3; }
			if(toolTrendLineU4==null) { toolTrendLineU4 = Tools.Create<TrendLine>(); toolTrendLineU4.Color=Color.Aqua;toolTrendLineU4.Width=3; }			
			if(toolTrendLineD1==null) { toolTrendLineD1 = Tools.Create<TrendLine>(); toolTrendLineD1.Color=Color.Aqua;toolTrendLineD1.Width=3; }
			if(toolTrendLineD2==null) { toolTrendLineD2 = Tools.Create<TrendLine>(); toolTrendLineD2.Color=Color.Aqua;toolTrendLineD2.Width=3; }
			if(toolTrendLineD3==null) { toolTrendLineD3 = Tools.Create<TrendLine>(); toolTrendLineD3.Color=Color.Aqua;toolTrendLineD3.Width=3; }	
			if(toolTrendLineD4==null) { toolTrendLineD4 = Tools.Create<TrendLine>(); toolTrendLineD4.Color=Color.Aqua;toolTrendLineD4.Width=3; }	
			
			if(toolText==null) { toolText  = Tools.Create<Text>();toolText.Color=Color.Aqua; }
			if(toolText1==null) { toolText1 = Tools.Create<Text>();toolText1.Color=Color.Aqua; }
			
			if(tU1==null) { tU1 = Tools.Create<Text>(); tU1.Color=Color.Aqua; }
			if(tU2==null) { tU2 = Tools.Create<Text>(); tU2.Color=Color.Aqua; }
			if(tU3==null) { tU3 = Tools.Create<Text>(); tU3.Color=Color.Aqua; }
			if(tU4==null) { tU4 = Tools.Create<Text>(); tU4.Color=Color.Aqua; }
			
			if(tD1==null) { tD1 = Tools.Create<Text>(); tD1.Color=Color.Aqua; }
			if(tD2==null) { tD2 = Tools.Create<Text>(); tD2.Color=Color.Aqua; }
			if(tD3==null) { tD3 = Tools.Create<Text>(); tD3.Color=Color.Aqua; }
			if(tD4==null) { tD4 = Tools.Create<Text>(); tD4.Color=Color.Aqua; }
        }        
Beispiel #9
0
        public void OpacityNewValue()
        {
            Chart chart = new Chart();

            chart.Width  = 400;
            chart.Height = 300;


            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = TrendLineToTest;

            chart.TrendLines.Add(trendLine);

            _isLoaded     = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();

            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                trendLine.Opacity = 0.5;
                Assert.AreEqual(0.5, trendLine.Opacity, Common.HighPrecisionDelta);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Beispiel #10
0
        public void TestTrendLineSerialization()
        {
            Chart chart = new Chart();

            chart.Width  = 400;
            chart.Height = 300;

            _isLoaded = false;

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            TrendLine trendLine = new TrendLine();

            trendLine.Value = 10;
            chart.TrendLines.Add(trendLine);

            DataSeries ds = new DataSeries();
            DataPoint  dp = new DataPoint();

            dp.YValue = 20;
            ds.DataPoints.Add(dp);
            chart.Series.Add(ds);

            Window window = new Window();

            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                MessageBox.Show(XamlWriter.Save(trendLine));
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
        private void BuildQuasiExtremums(int srcCount)
        {
            double?lastPeak  = null;
            var    peakPrice = 0.0;

            for (var i = 0; i < srcCount; i++)
            {
                var index     = GetSourcePrice(i, 0);
                var indexNext = i < srcCount?GetSourcePrice(i + 1, 0) : index;

                // если находимся в зоне перекупленности / перепроданности,
                // если след. точка ниже (выше для перепроданности),
                // если текущая точка выше последнего максимума (ниже минимума...)

                var margUp = index >= MargUpper;
                var margDn = index <= MargLower;

                if ((margUp && indexNext < index &&
                     index > (lastPeak.HasValue ? lastPeak.Value : double.MinValue)) ||
                    (margDn && indexNext > index && index < (lastPeak.HasValue ? lastPeak.Value : double.MaxValue)))
                {// + или - экстремум
                    // нарисовать палочку от peakPrice вверх или вниз
                    var seriesPeakBar = SeriesSources.Count == 2
                                            ? SeriesSources[1]
                                            : SeriesSources[0];
                    if (seriesPeakBar is StockSeries)
                    {
                        var stockSrc = (StockSeries)seriesPeakBar;
                        peakPrice = i < 0 || i >= stockSrc.Data.Count
                                        ? 0
                                        : ExtremumDirection == ExtremumBarDirection.СверхуВниз
                                              ? (double)stockSrc.Data.Candles[i].low :
                                    (double)stockSrc.Data.Candles[i].high;
                    }
                    if (seriesPeakBar is LineSeries)
                    {
                        var lineSrc = (LineSeries)seriesPeakBar;
                        peakPrice = i < 0 || i >= lineSrc.Data.Count
                                        ? 0 : lineSrc.Data[i];
                    }

                    var line = new TrendLine();
                    line.linePoints.Add(new PointD(i, peakPrice));
                    line.linePoints.Add(ExtremumDirection == ExtremumBarDirection.СверхуВниз
                                            ? new PointD(i, double.MinValue)
                                            : new PointD(i, double.MaxValue));

                    seriesExtr.data.Add(line);
                    // нарисовать столбик от цены вверх или вниз
                    lastPeak = index;
                    continue;
                }
                if (!margUp && margDn == false)
                {// конец отсчета экстремума
                    lastPeak = null;
                    continue;
                }
            }
        }
        private void BuildClassicExtremums(int srcCount)
        {
            var seriesPeakBar = SeriesSources.Count == 2
                                            ? SeriesSources[1]
                                            : SeriesSources[0];

            for (var i = ClassicExtremumBar; i < srcCount - ClassicExtremumBar; i++)
            {
                bool isMin = true, isMax = true;
                var  priceExt = GetSourcePrice(i, 0);
                for (var j = i - ClassicExtremumBar; j <= i + ClassicExtremumBar; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }
                    var price = GetSourcePrice(j, 0);
                    if (price > priceExt)
                    {
                        isMax = false;
                    }
                    if (price < priceExt)
                    {
                        isMin = false;
                    }
                    if (!isMax && !isMin)
                    {
                        break;
                    }
                }
                if (isMin || isMax)
                {
                    double peakPrice = 0;
                    if (seriesPeakBar is StockSeries)
                    {
                        var stockSrc = (StockSeries)seriesPeakBar;
                        peakPrice = i < 0 || i >= stockSrc.Data.Count
                                        ? 0
                                        : ExtremumDirection == ExtremumBarDirection.СверхуВниз
                                              ? (double)stockSrc.Data.Candles[i].low
                                              : (double)stockSrc.Data.Candles[i].high;
                    }
                    if (seriesPeakBar is LineSeries)
                    {
                        var lineSrc = (LineSeries)seriesPeakBar;
                        peakPrice = i < 0 || i >= lineSrc.Data.Count
                                        ? 0 : lineSrc.Data[i];
                    }

                    var line = new TrendLine();
                    line.linePoints.Add(new PointD(i, peakPrice));
                    line.linePoints.Add(ExtremumDirection == ExtremumBarDirection.СверхуВниз
                                            ? new PointD(i, double.MinValue)
                                            : new PointD(i, double.MaxValue));

                    seriesExtr.data.Add(line);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TrendLinePenetrationArgs"/> class.
 /// </summary>
 /// <param name="trendLine">Reference to trendline being penetrated</param>
 /// <param name="trendLinePenetrationEnum">Penetration type</param>
 /// <param name="series">Reference to the Series that penetrated the trendline</param>
 public TrendLinePenetrationArgs(TrendLine trendLine,
                                 TrendLinePenetrationEnum trendLinePenetrationEnum,
                                 Series series)
 {
     TrendLine = trendLine;
     TrendLinePenetrationType = trendLinePenetrationEnum;
     Series = series;
 }
Beispiel #14
0
 protected override void Init()
 {
     Print("Init var={0}", ver);
     k        = 1;
     tl       = Tools.Create <TrendLine>();
     tl.Color = Color.HotPink;
     tl.Width = 3;
 }
Beispiel #15
0
        private void TrendLineTypeDialogLoad(object sender, EventArgs e)
        {
            // заполнить список линий
            var w          = imageListLarge.ImageSize.Width;
            var h          = imageListLarge.ImageSize.Height;
            var rectWorld  = new RectangleD(0, 0, w, h);
            var rectCanvas = new Rectangle(0, 0, w, h);

            var colors     = new [] { Color.BlanchedAlmond, Color.GreenYellow, Color.PaleTurquoise };
            var colorIndex = 0;

            foreach (TrendLine.TrendLineStyle lineType in Enum.GetValues(typeof(TrendLine.TrendLineStyle)))
            {
                var bmp  = new Bitmap(w, h);
                var line = new TrendLine();
                line.AddPoint(h * 0.23, w - 5);
                line.AddPoint(h * 0.77, 5);
                if (lineType == TrendLine.TrendLineStyle.Отрезок ||
                    lineType == TrendLine.TrendLineStyle.Окружность || lineType == TrendLine.TrendLineStyle.ЛинияСМаркерами ||
                    lineType == TrendLine.TrendLineStyle.ОтрезокСМаркерами)
                {
                    line.linePoints[1] = new PointD(h * 0.32, w - 16);
                    line.linePoints[0] = new PointD(h * 0.68, 16);
                }

                line.LineColor      = Color.Black;
                line.ShapeFillColor = colors[colorIndex];
                line.LineStyle      = lineType;
                colorIndex++;
                if (colorIndex == colors.Length)
                {
                    colorIndex = 0;
                }

                using (var gr = Graphics.FromImage(bmp))
                    using (var brushes = new BrushesStorage())
                        using (var pens = new PenStorage())
                        {
                            gr.SmoothingMode = SmoothingMode.AntiAlias;
                            line.Draw(gr, rectWorld, rectCanvas, pens, brushes);
                        }

                imageListLarge.Images.Add(bmp);
                var item = listView.Items.Add(lineType.ToString(),
                                              EnumFriendlyName <TrendLine.TrendLineStyle> .GetString(lineType),
                                              imageListLarge.Images.Count - 1);
                item.Tag = lineType;
                if (lineType == selectedStyle)
                {
                    item.Selected = true;
                }
            }

            // привязать картинки к списку
            listView.LargeImageList = imageListLarge;
            listView.SmallImageList = imageListLarge;
        }
Beispiel #16
0
        public override IChartInteractiveObject LoadObject(XmlElement objectNode, CandleChartControl owner, bool trimObjectsOutOfHistory = false)
        {
            var obj = new TrendLine();

            obj.LoadFromXML(objectNode, owner);
            obj.Owner = this;
            data.Add(obj);
            return(obj);
        }
Beispiel #17
0
        /// <summary>
        /// Вспомогательный метод прорисовки отрезка
        /// </summary>
        private TrendLine MakeTrendShelf(double x, double y, Color color, double dx = 0, double dy = 0)
        {
            var line = new TrendLine {
                LineStyle = TrendLine.TrendLineStyle.Отрезок, LineColor = color
            };

            line.linePoints.Add(new PointD(x + dx, y + dy));
            line.linePoints.Add(new PointD(x, y));
            return(line);
        }
 internal void FireTrendLinePenetration(TrendLine trendLine,
                                        TrendLinePenetrationEnum trendLinePenetrationEnum,
                                        Series series)
 {
     if (TrendLinePenetration != null)
     {
         TrendLinePenetration(this,
                              new TrendLinePenetrationArgs(trendLine, trendLinePenetrationEnum, series));
     }
 }
Beispiel #19
0
        private void nbOrder_ValueChanged(object sender, C1.WPF.PropertyChangedEventArgs <double> e)
        {
            TrendLine tl = DataContext as TrendLine;

            if (tl != null)
            {
                tl.Order = (int)nbOrder.Value;
                tl.Label = CreateLabel(tl);
            }
        }
        public Dynamic()
        {
            InitializeComponent();

            chart.Data.ItemsSource = _pts;
            chart.ChartType        = ChartType.Line;

            XYDataSeries ds = new XYDataSeries()
            {
                XValueBinding             = new Binding("X"),
                ValueBinding              = new Binding("Y"),
                ConnectionStrokeThickness = 2,
                Label = "raw",
//        ConnectionStroke = new SolidColorBrush(Colors.DarkGray)
            };

            chart.Data.Children.Add(ds);

            _tlmin = new TrendLine()
            {
                FitType       = FitType.MinY,
                XValueBinding = new Binding("X"),
                ValueBinding  = new Binding("Y"),
                Label         = "min",
//        ConnectionStroke = new SolidColorBrush(Colors.Blue)
            };

            _tlmax = new TrendLine()
            {
                FitType       = FitType.MaxY,
                XValueBinding = new Binding("X"),
                ValueBinding  = new Binding("Y"),
                Label         = "max",
//        ConnectionStroke = new SolidColorBrush(Colors.Red)
            };

            _tlavg = new TrendLine()
            {
                FitType       = FitType.AverageY,
                XValueBinding = new Binding("X"),
                ValueBinding  = new Binding("Y"),
                Label         = "avg",
//        ConnectionStroke = new SolidColorBrush(Colors.Green)
            };

            chart.View.AxisY.Min = -1000;
            chart.View.AxisY.Max = 1000;

            dt = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.2)
            };
            dt.Tick += (s, e) => Update();
            dt.Start();
        }
        public void BuildSeries(ChartControl chart)
        {
            series.data.Clear();
            //var candles = chart.StockSeries.Data.Candles;

            if (SeriesSources[0].GetType() == typeof(CandlestickSeries))
            {
                var candles = ((StockSeries)SeriesSources[0]).Data.Candles;
                if (candles.Count < period)
                {
                    return;
                }

                for (var i = period; i < candles.Count; i += period)
                {
                    var turtle = new TrendLine
                    {
                        LineColor      = clLine,
                        ShapeAlpha     = 128,
                        ShapeFillColor = Color.Green,
                        LineStyle      = Shape == IndicatorShape.Черепаха ?
                                         TrendLine.TrendLineStyle.Черепаха : TrendLine.TrendLineStyle.Пэкмен
                    };
                    turtle.AddPoint(i - period, (double)candles[i - period].open);
                    turtle.AddPoint(i, (double)candles[i].close);
                    series.data.Add(turtle);
                }
            }
            else
            {
                if (SeriesSources[0].GetType() == typeof(LineSeries))
                {
                    var candles = ((LineSeries)SeriesSources[0]).Data;
                    if (candles.Count < period)
                    {
                        return;
                    }

                    for (var i = period; i < candles.Count; i += period)
                    {
                        var turtle = new TrendLine
                        {
                            LineColor      = clLine,
                            ShapeAlpha     = 128,
                            ShapeFillColor = Color.Green,
                            LineStyle      = Shape == IndicatorShape.Черепаха ?
                                             TrendLine.TrendLineStyle.Черепаха : TrendLine.TrendLineStyle.Пэкмен
                        };
                        turtle.AddPoint(i - period, (double)candles[i - period]);
                        turtle.AddPoint(i, (double)candles[i]);
                        series.data.Add(turtle);
                    }
                }
            }
        }
        public void BuildSeries(ChartControl chart)
        {
            seriesTrendLine.data.Clear();
            // актуализировать серии-источники
            ActualizeSeries();
            // по каждой паре серий строить диверы и переводить их Х
            // координаты в масштаб графика (если ТФ отличаются)
            var signs = new Dictionary <int, List <DiverMarker> >();

            foreach (var src in sets)
            {
                if (src.seriesDest == null || src.seriesSrc == null)
                {
                    continue;
                }
                if (src.seriesDest.isDisposed || src.seriesSrc.isDisposed)
                {
                    continue;
                }
                if (src.seriesDest is IPriceQuerySeries == false ||
                    src.seriesSrc is IPriceQuerySeries == false)
                {
                    continue;
                }
                BuildDivers(src, signs);
            }

            // отобразить
            foreach (var pair in signs)
            {
                var markers = pair.Value;
                var index   = pair.Key;
                var sign    = Math.Sign(markers.Sum(m => m.sign));
                if (sign == 0)
                {
                    sign = markers[0].sign;
                }
                var price = (double)(owner.StockSeries.GetPrice(index) ?? 0);

                var text = string.Join(", ",
                                       markers.Select(m => string.Format("{0}:{1}", m.title, m.sign > 0 ? '^' : 'v')));

                var line = new TrendLine
                {
                    LineStyle      = TrendLine.TrendLineStyle.СвечнаяСтрелка,
                    LineColor      = sign > 0 ? ColorArrowUp : ColorArrowDown,
                    ShapeAlpha     = 192,
                    ShapeFillColor = sign > 0 ? ColorArrowUp : ColorArrowDown,
                    Comment        = text
                };
                line.AddPoint(index, price - sign * price * 0.01);
                line.AddPoint(index, price);
                seriesTrendLine.data.Add(line);
            }
        }
Beispiel #23
0
        private void cbFit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TrendLine tl = DataContext as TrendLine;

            if (tl != null)
            {
                tl.FitType = (FitType)cbFit.SelectedIndex;
                tl.Label   = CreateLabel(tl);
                UpdateControls();
            }
        }
Beispiel #24
0
 string CreateLabel(TrendLine tl)
 {
     if (tl.FitType == FitType.Polynom || tl.FitType == FitType.Fourier)
     {
         return(string.Format("{0} {1}", tl.FitType, tl.Order));
     }
     else
     {
         return(string.Format("{0}", tl.FitType));
     }
 }
Beispiel #25
0
        public double GetAverageValue(String DataType)
        {
            HistoryData TrendLine;

            m_DataHistoryArray.TryGetValue(DataType, out TrendLine);
            if (TrendLine != null)
            {
                return(TrendLine.GetAverageValue());
            }

            return(0);
        }
        private void AddLinePoint(int index, float price)
        {
            var line = new TrendLine
            {
                LineColor = LineColor,
                LineStyle = LineStyle
            };

            line.AddPoint(index - 0.4, price);
            line.AddPoint(index + 0.4, price);
            mainLine.data.Add(line);
        }
Beispiel #27
0
        public Dynamic()
        {
            InitializeComponent();

              chart.Data.ItemsSource = _pts;
              chart.ChartType = ChartType.Line;

              XYDataSeries ds = new XYDataSeries()
              {
            XValueBinding = new Binding("X"),
            ValueBinding = new Binding("Y"),
            ConnectionStrokeThickness = 2,
            Label = "raw",
            //        ConnectionStroke = new SolidColorBrush(Colors.DarkGray)
              };

              chart.Data.Children.Add(ds);

              _tlmin = new TrendLine()
              {
            FitType = FitType.MinY,
            XValueBinding = new Binding("X"),
            ValueBinding = new Binding("Y"),
            Label = "min",
            //        ConnectionStroke = new SolidColorBrush(Colors.Blue)
              };

              _tlmax = new TrendLine()
              {
            FitType = FitType.MaxY,
            XValueBinding = new Binding("X"),
            ValueBinding = new Binding("Y"),
            Label = "max",
            //        ConnectionStroke = new SolidColorBrush(Colors.Red)
              };

              _tlavg = new TrendLine()
              {
            FitType = FitType.AverageY,
            XValueBinding = new Binding("X"),
            ValueBinding = new Binding("Y"),
            Label = "avg",
            //        ConnectionStroke = new SolidColorBrush(Colors.Green)
              };

              chart.View.AxisY.Min = -1000;
              chart.View.AxisY.Max = 1000;

              dt = new DispatcherTimer()
            { Interval = TimeSpan.FromSeconds(0.2) };
              dt.Tick += (s, e) => Update();
              dt.Start();
        }
Beispiel #28
0
        protected override void Init()
        {
            _ftoInd = GetIndicator <FisherTransformOscillator>(Instrument.Id, Timeframe);
            mind    = double.MaxValue;
            maxu    = double.MinValue;
            kf      = 0.0;

            toolTrendLineU1 = Tools.Create <TrendLine>(); toolTrendLineU1.Color = Color.Aqua; toolTrendLineU1.Width = 3;
            toolTrendLineU2 = Tools.Create <TrendLine>(); toolTrendLineU2.Color = Color.Aqua; toolTrendLineU2.Width = 3;
            toolTrendLineU3 = Tools.Create <TrendLine>(); toolTrendLineU3.Color = Color.Aqua; toolTrendLineU3.Width = 3;
            toolTrendLineD1 = Tools.Create <TrendLine>(); toolTrendLineD1.Color = Color.Aqua; toolTrendLineD1.Width = 3;
            toolTrendLineD2 = Tools.Create <TrendLine>(); toolTrendLineD2.Color = Color.Aqua; toolTrendLineD2.Width = 3;
            toolTrendLineD3 = Tools.Create <TrendLine>(); toolTrendLineD3.Color = Color.Aqua; toolTrendLineD3.Width = 3;
        }
        private void AddLine(int scaleIndex, int i, double spanPrice)
        {
            var line = new TrendLine
            {
                LineColor    = colors[scaleIndex],
                LineStyle    = TrendLine.TrendLineStyle.Линия,
                PenDashStyle = styles[scaleIndex],
                PenWidth     = widths[scaleIndex]
            };

            line.AddPoint(i, 0);
            line.AddPoint(i, spanPrice);
            series.data.Add(line);
        }
Beispiel #30
0
        private void udYIntercept_ValueChanged(object sender, EventArgs e)
        {
            ChartData cd = c1Chart1.ChartGroups[0].ChartData;

            if (cd.TrendsList.Count > 0)
            {
                TrendLine tl = cd.TrendsList[0];

                tl.RegressionOptions.YIntercept = (double)udYIntercept.Value;

                UpdateStatisticsLabel();
                UpdateFormulaLabel();
            }
        }
        void AddTrendLine()
        {
            TrendLine tl = new TrendLine()
              {
            XValuesSource = x,
            ValuesSource = y,
            Order = 4,
              };

              chart.Data.Children.Add(tl);

              TrendLineEditor tle = new TrendLineEditor() { Margin = new Thickness(4) };
              tle.DataContext = tl;
              sp.Children.Add(tle);
        }
Beispiel #32
0
        private void cbUseYIntercept_CheckedChanged(object sender, EventArgs e)
        {
            ChartGroup cg = c1Chart1.ChartGroups[0];

            if (cg.ChartData.TrendsList.Count > 0)
            {
                TrendLine tl = cg.ChartData.TrendsList[0];
                tl.RegressionOptions.UseYIntercept = cbUseYIntercept.Checked;

                UpdateStatisticsLabel();
                UpdateFormulaLabel();
            }

            udYIntercept.Visible = cbUseYIntercept.Checked;
        }
Beispiel #33
0
        void UpdateControls()
        {
            TrendLine tl = DataContext as TrendLine;

            if (tl != null)
            {
                if (tl.FitType == FitType.Polynom || tl.FitType == FitType.Fourier)
                {
                    hOrder.Visibility = Visibility.Visible;
                }
                else
                {
                    hOrder.Visibility = Visibility.Collapsed;
                }
            }
        }