Example #1
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]);
                }
            }
        }
Example #2
0
        public void SetCandles(List <Candle> candles)
        {
            try
            {
                if (candles == null)
                {
                    return;
                }

                if (_myCandles != null && _lastCount == candles.Count &&
                    ServerMaster.StartProgram != ServerStartProgramm.IsTester &&
                    ServerMaster.StartProgram != ServerStartProgramm.IsOsData &&
                    _lastPrice == candles[candles.Count - 1].Close)
                {
                    // обновляем свечи только когда они действительно обновились
                    return;
                }

                bool canReload = ServerMaster.StartProgram != ServerStartProgramm.IsOsOptimizer;


                _lastCount = candles.Count;
                _lastPrice = candles[candles.Count - 1].Close;
                _myCandles = candles;

                if (ChartCandle != null)
                {
                    if (canReload)
                    {
                        _lastCandleIncome = DateTime.Now;
                        ChartCandle.ProcessCandles(candles);
                        ChartCandle.ProcessPositions(_myPosition);
                    }

                    if (_indicatorsCandles != null)
                    {
                        for (int i = 0; i < _indicatorsCandles.Count; i++)
                        {
                            _indicatorsCandles[i].Process(candles);

                            if (canReload)
                            {
                                ChartCandle.ProcessIndicator(_indicatorsCandles[i]);
                            }
                        }
                    }
                    if (canReload && _alertArray != null && _alertArray.Count != 0)
                    {
                        ChartCandle.ClearAlerts(_alertArray);

                        for (int i = 0; _alertArray != null && i < _alertArray.Count; i++)
                        {
                            if (_alertArray[i].TypeAlert == AlertType.ChartAlert)
                            {
                                ChartCandle.PaintAlert((AlertToChart)_alertArray[i]);
                            }
                        }
                    }
                }
            }
            catch (Exception error)
            {
                SendErrorMessage(error);
            }
        }