Пример #1
0
        private void PaintActivTab(int tabNum)
        {
            if (_lastTabNum == tabNum)
            {
                return;
            }
            _lastTabNum = tabNum;

            _chart.StopPaint();

            _chart.Clear();

            if (tabNum < _panel.TabsSimple.Count)
            {
                _chart.PaintCandles(_panel.TabsSimple[tabNum].CandlesFinishedOnly);
                _chart.StartPaint(ChartHostPanel, RectChart);
                _chart.PaintPositions(_panel.TabsSimple[tabNum].PositionsAll);

                for (int i = 0; _panel.TabsSimple[tabNum].Indicators != null && i < _panel.TabsSimple[tabNum].Indicators.Count; i++)
                {
                    ChartArea area = _chart.CreateArea("Area" + _panel.TabsSimple[tabNum].Indicators[i].Name, 15);
                    _panel.TabsSimple[tabNum].Indicators[i].NameSeries = _chart.CreateSeries(area,
                                                                                             _panel.TabsSimple[tabNum].Indicators[i].TypeIndicator, _panel.TabsSimple[tabNum].Indicators[i].NameSeries);

                    _chart.PaintIndicator(_panel.TabsSimple[tabNum].Indicators[i]);
                }
            }
            else
            {
                tabNum = tabNum - _panel.TabsSimple.Count;

                _chart.PaintCandles(_panel.TabsIndex[tabNum].Candles);
                _chart.StartPaint(ChartHostPanel, RectChart);

                for (int i = 0; _panel.TabsIndex[tabNum].Indicators != null && i < _panel.TabsIndex[tabNum].Indicators.Count; i++)
                {
                    ChartArea area = _chart.CreateArea("Area" + _panel.TabsIndex[tabNum].Indicators[i].Name, 15);
                    _panel.TabsIndex[tabNum].Indicators[i].NameSeries = _chart.CreateSeries(area,
                                                                                            _panel.TabsIndex[tabNum].Indicators[i].TypeIndicator, _panel.TabsIndex[tabNum].Indicators[i].Name + i);

                    _chart.PaintIndicator(_panel.TabsIndex[tabNum].Indicators[i]);
                }
            }
        }
Пример #2
0
        private void PaintActivTab(int tabNum)
        {
            if (_lastTabNum == tabNum)
            {
                return;
            }
            _lastTabNum = tabNum;

            if (_chart != null)
            {
                _chart.StopPaint();
                _chart.ClearDataPointsAndSizeValue();
                _chart.Delete();
            }


            if (tabNum < _panel.TabsSimple.Count)
            {
                _chart = new ChartPainter(_panel.NameStrategyUniq);
                _chart.ProcessCandles(_panel.TabsSimple[tabNum].CandlesFinishedOnly);
                _chart.StartPaintPrimeChart(ChartHostPanel, RectChart);
                _chart.ProcessPositions(_panel.TabsSimple[tabNum].PositionsAll);

                for (int i = 0; _panel.TabsSimple[tabNum].Indicators != null && i < _panel.TabsSimple[tabNum].Indicators.Count; i++)
                {
                    ChartArea area = _chart.CreateArea("Area" + _panel.TabsSimple[tabNum].Indicators[i].Name, 15);
                    _panel.TabsSimple[tabNum].Indicators[i].NameSeries = _chart.CreateSeries(area,
                                                                                             _panel.TabsSimple[tabNum].Indicators[i].TypeIndicator, _panel.TabsSimple[tabNum].Indicators[i].NameSeries);

                    _chart.ProcessIndicator(_panel.TabsSimple[tabNum].Indicators[i]);
                }
            }
            else
            {
                tabNum = tabNum - _panel.TabsSimple.Count;
                _chart = new ChartPainter(_panel.NameStrategyUniq);
                _chart.ProcessCandles(_panel.TabsIndex[tabNum].Candles);
                _chart.StartPaintPrimeChart(ChartHostPanel, RectChart);

                for (int i = 0; _panel.TabsIndex[tabNum].Indicators != null && i < _panel.TabsIndex[tabNum].Indicators.Count; i++)
                {
                    ChartArea area = _chart.CreateArea("Area" + _panel.TabsIndex[tabNum].Indicators[i].Name, 15);
                    _panel.TabsIndex[tabNum].Indicators[i].NameSeries = _chart.CreateSeries(area,
                                                                                            _panel.TabsIndex[tabNum].Indicators[i].TypeIndicator, _panel.TabsIndex[tabNum].Indicators[i].Name + i);

                    _chart.ProcessIndicator(_panel.TabsIndex[tabNum].Indicators[i]);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// создать новый индикатор. Если уже есть с таким именем, возвращается имеющийся
        /// </summary>
        /// <param name="indicator">индикатор, который нужно интегрировать в чарт</param>
        /// <param name="nameArea">имя области, на которой следует прорисовать индикатор</param>
        /// <returns></returns>
        public IIndicatorCandle CreateIndicator(IIndicatorCandle indicator, string nameArea)
        {
            try
            {
                indicator.NameArea = nameArea;

                if (_indicatorsCandles != null)
                {
                    // проверяем, есть ли такой индикатор в коллекции
                    for (int i = 0; i < _indicatorsCandles.Count; i++)
                    {
                        if (_indicatorsCandles[i].Name == indicator.Name)
                        {
                            return(_indicatorsCandles[i]);
                        }
                    }
                }

                bool inNewArea = true;

                if (ChartCandle.GetChartArea(nameArea) != null)
                {
                    inNewArea = false;
                }

                List <List <decimal> > values = indicator.ValuesToChart;

                for (int i = 0; i < values.Count; i++)
                {
                    if (inNewArea == false)
                    {
                        indicator.NameSeries = ChartCandle.CreateSeries(ChartCandle.GetChartArea(nameArea),
                                                                        indicator.TypeIndicator, indicator.Name + i);
                    }
                    else
                    {
                        ChartArea area = ChartCandle.CreateArea(nameArea, 15);
                        indicator.NameSeries = ChartCandle.CreateSeries(area,
                                                                        indicator.TypeIndicator, indicator.Name + i);
                    }
                }

                if (_indicatorsCandles == null)
                {
                    _indicatorsCandles = new List <IIndicatorCandle>();
                    _indicatorsCandles.Add(indicator);
                }
                else
                {
                    _indicatorsCandles.Add(indicator);
                }

                Save();
                ReloadContext();
                indicator.NeadToReloadEvent += indicator_NeadToReloadEvent;
                indicator_NeadToReloadEvent(indicator);
                return(indicator);
            }
            catch (Exception error)
            {
                SendErrorMessage(error);
                return(null);
            }
        }