Example #1
0
 private void ButtonPaint_Click(object sender, RoutedEventArgs e)
 {
     _painter.Clear();
     if (_bot.MergeCandles != null && _bot.MergeCandles.Count != 0)
     {
         _painter.PaintCandles(_bot.MergeCandles);
     }
 }
Example #2
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]);
                }
            }
        }
Example #3
0
        public void SetCandles(List <Candle> candles)
        {
            try
            {
                if (candles == null)
                {
                    return;
                }

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

                bool canReload = true;

                if (!ServerMaster.IsTester &&
                    _reloadState == ChartReloadState.OneSecond &&
                    _lastCandleIncome.AddSeconds(1) > DateTime.Now)
                {
                    canReload = false;
                }

                if (!ServerMaster.IsTester &&
                    _reloadState == ChartReloadState.FiveSecond &&
                    _lastCandleIncome.AddSeconds(5) > DateTime.Now)
                {
                    canReload = false;
                }


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

                if (_chartCandle != null)
                {
                    if (canReload)
                    {
                        _lastCandleIncome = DateTime.Now;
                        _chartCandle.PaintCandles(candles);
                        _chartCandle.PaintPositions(_myPosition);
                    }

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

                            if (canReload)
                            {
                                _chartCandle.PaintIndicator(_indicatorsCandles[i]);
                            }
                        }
                    }
                    if (canReload)
                    {
                        _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);
            }
        }