コード例 #1
0
ファイル: PatternController.cs プロジェクト: w1r2p1/OsEngine
        /// <summary>
        /// отрисовать осноной чарт
        /// </summary>
        public void PaintPrimeChart()
        {
            if (string.IsNullOrEmpty(SecurityToInter))
            {
                return;
            }


            if (_chartHost == null ||
                _rectChart == null)
            {
                return;
            }

            _chart.Clear();
            _chart.StartPaint(_chartHost, _rectChart);

            MinerCandleSeries series = CandleSeries.Find(ser => ser.Security.Name == SecurityToInter);

            if (series == null)
            {
                return;
            }

            _chart.SetCandles(series.Candles);

            if (_volume == null)
            {
                _volume = new Volume("Volume", false);
                _volume = (Volume)_chart.CreateIndicator(_volume, "VolumeArea");
            }
            _volume.Process(series.Candles);
        }
コード例 #2
0
// Индикаторы

        /// <summary>
        /// создать индикатор на свечном графике. Начать его прорисовку на графике. Прогрузить его и подписать на обновление.
        /// </summary>
        /// <param name="indicator">индикатор</param>
        /// <param name="nameArea">название области на которую он будет помещён. Главная по умолчанию "Prime"</param>
        /// <returns></returns>
        public IIndicatorCandle CreateCandleIndicator(IIndicatorCandle indicator, string nameArea)
        {
            return(_chartMaster.CreateIndicator(indicator, nameArea));
        }
コード例 #3
0
        /// <summary>
        /// кнопка принять
        /// </summary>
        private void ButtonAccept_Click(object sender, RoutedEventArgs e)
        {
            string areaName = _gridViewAreas.SelectedCells[0].Value.ToString();

            if (areaName == "NewArea")
            {
                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.AreaIsCreate("NewArea" + i) == false)
                    {
                        areaName = "NewArea" + i;
                        break;
                    }
                }
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Trades")
            {
                _chartMaster.CreateTickChart();
            }



            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "KalmanFilter") // сюда добавить новый индикатор чтоб он стал доступен для выбора
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "KalmanFilter" + i) == false)
                    {
                        name = "KalmanFilter" + i;
                        break;
                    }
                }
                IndicatorCandle = new KalmanFilter(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }

            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Moving Average")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Sma" + i) == false)
                    {
                        name = "Sma" + i;
                        break;
                    }
                }
                IndicatorCandle = new MovingAverage(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }

            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Volume")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Volume" + i) == false)
                    {
                        name = "Volume" + i;
                        break;
                    }
                }

                IndicatorCandle = new Volume(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Price Channel")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Price Channel" + i) == false)
                    {
                        name = "Price Channel" + i;
                        break;
                    }
                }
                IndicatorCandle = new PriceChannel(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Bollinger")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Bollinger" + i) == false)
                    {
                        name = "Bollinger" + i;
                        break;
                    }
                }
                IndicatorCandle = new Bollinger(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "BFMFI")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "BFMFI" + i) == false)
                    {
                        name = "BFMFI" + i;
                        break;
                    }
                }
                IndicatorCandle = new BfMfi(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "BullsPower")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "BullsPower" + i) == false)
                    {
                        name = "BullsPower" + i;
                        break;
                    }
                }
                IndicatorCandle = new BullsPower(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "CMO")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "CMO" + i) == false)
                    {
                        name = "CMO" + i;
                        break;
                    }
                }
                IndicatorCandle = new Cmo(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "BearsPower")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "BearsPower" + i) == false)
                    {
                        name = "BeasPower" + i;
                        break;
                    }
                }
                IndicatorCandle = new BearsPower(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "StochasticOscillator")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "StochasticOscillator" + i) == false)
                    {
                        name = "StochasticOscillator" + i;
                        break;
                    }
                }
                IndicatorCandle = new StochasticOscillator(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "RSI")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "RSI" + i) == false)
                    {
                        name = "RSI" + i;
                        break;
                    }
                }
                IndicatorCandle = new Rsi(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "ROC")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "ROC" + i) == false)
                    {
                        name = "ROC" + i;
                        break;
                    }
                }
                IndicatorCandle = new Roc(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "RVI")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "RVI" + i) == false)
                    {
                        name = "RVI" + i;
                        break;
                    }
                }
                IndicatorCandle = new Rvi(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Alligator")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Alligator" + i) == false)
                    {
                        name = "Alligator" + i;
                        break;
                    }
                }
                IndicatorCandle = new Alligator(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "AO")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "AO" + i) == false)
                    {
                        name = "AO" + i;
                        break;
                    }
                }
                IndicatorCandle = new AwesomeOscillator(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "AccumulationDistribution")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "AccumulationDistribution" + i) == false)
                    {
                        name = "AccumulationDistribution" + i;
                        break;
                    }
                }
                IndicatorCandle = new AccumulationDistribution(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Force Index")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Force Index" + i) == false)
                    {
                        name = "Force Index" + i;
                        break;
                    }
                }
                IndicatorCandle = new ForceIndex(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "OnBalanceVolume")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "OnBalanceVolume" + i) == false)
                    {
                        name = "OnBalanceVolume" + i;
                        break;
                    }
                }
                IndicatorCandle = new OnBalanceVolume(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Fractal")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Fractal" + i) == false)
                    {
                        name = "Fractal" + i;
                        break;
                    }
                }
                IndicatorCandle = new Fractal(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "ADX")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "ADX" + i) == false)
                    {
                        name = "ADX" + i;
                        break;
                    }
                }
                IndicatorCandle = new Adx(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "ATR")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "ATR" + i) == false)
                    {
                        name = "ATR" + i;
                        break;
                    }
                }
                IndicatorCandle = new Atr(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Price Oscillator")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Price Oscillator" + i) == false)
                    {
                        name = "Price Oscillator" + i;
                        break;
                    }
                }
                IndicatorCandle = new PriceOscillator(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "MACD Histogram")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "MACD Histogram" + i) == false)
                    {
                        name = "MACD Histogram" + i;
                        break;
                    }
                }
                IndicatorCandle = new MacdHistogram(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "MACD Line")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "MACD Line" + i) == false)
                    {
                        name = "MACD Line" + i;
                        break;
                    }
                }
                IndicatorCandle = new MacdLine(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Momentum")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Momentum" + i) == false)
                    {
                        name = "Momentum" + i;
                        break;
                    }
                }
                IndicatorCandle = new Momentum(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "MoneyFlowIndex")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "MoneyFlowIndex" + i) == false)
                    {
                        name = "MoneyFlowIndex" + i;
                        break;
                    }
                }
                IndicatorCandle = new MoneyFlowIndex(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Envelops")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Envelops" + i) == false)
                    {
                        name = "Envelops" + i;
                        break;
                    }
                }
                IndicatorCandle = new Envelops(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Efficiency Ratio")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "EfficiencyRatio" + i) == false)
                    {
                        name = "EfficiencyRatio" + i;
                        break;
                    }
                }
                IndicatorCandle = new EfficiencyRatio(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Adaptive Look Back")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Adaptive Look Back" + i) == false)
                    {
                        name = "Adaptive Look Back" + i;
                        break;
                    }
                }
                IndicatorCandle = new AdaptiveLookBack(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "IvashovRange")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "IvashovRange" + i) == false)
                    {
                        name = "IvashovRange" + i;
                        break;
                    }
                }
                IndicatorCandle = new IvashovRange(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }

            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Volume Oscillator")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Volume Oscillator" + i) == false)
                    {
                        name = "Volume Oscillator" + i;
                        break;
                    }
                }
                IndicatorCandle = new VolumeOscillator(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Parabolic SAR")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Parabolic SAR" + i) == false)
                    {
                        name = "Parabolic SAR" + i;
                        break;
                    }
                }
                IndicatorCandle = new ParabolicSaR(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }

            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "CCI")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "CCI" + i) == false)
                    {
                        name = "CCI" + i;
                        break;
                    }
                }
                IndicatorCandle = new Cci(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }


            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Standard Deviation")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Standard Deviation" + i) == false)
                    {
                        name = "Standard Deviation" + i;
                        break;
                    }
                }
                IndicatorCandle = new StandardDeviation(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "AC")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "AC" + i) == false)
                    {
                        name = "AC" + i;
                        break;
                    }
                }
                IndicatorCandle = new Ac(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "VerticalHorizontalFilter")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "VerticalHorizontalFilter" + i) == false)
                    {
                        name = "VerticalHorizontalFilter" + i;
                        break;
                    }
                }
                IndicatorCandle = new VerticalHorizontalFilter(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "WilliamsRange")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "WilliamsRange" + i) == false)
                    {
                        name = "WilliamsRange" + i;
                        break;
                    }
                }
                IndicatorCandle = new WilliamsRange(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Trix")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Trix" + i) == false)
                    {
                        name = "Trix" + i;
                        break;
                    }
                }
                IndicatorCandle = new Trix(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Ichimoku")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Ichimoku" + i) == false)
                    {
                        name = "Ichimoku" + i;
                        break;
                    }
                }
                IndicatorCandle = new  Ichimoku(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "TradeThread")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "TradeThread" + i) == false)
                    {
                        name = "TradeThread" + i;
                        break;
                    }
                }
                IndicatorCandle = new TradeThread(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Pivot")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Pivot" + i) == false)
                    {
                        name = "Pivot" + i;
                        break;
                    }
                }
                IndicatorCandle = new Pivot(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }
            if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Pivot Points")
            {
                string name = "";

                for (int i = 0; i < 30; i++)
                {
                    if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "PivotPoints" + i) == false)
                    {
                        name = "PivotPoints" + i;
                        break;
                    }
                }
                IndicatorCandle = new PivotPoints(_chartMaster.Name + name, true);
                _chartMaster.CreateIndicator(IndicatorCandle, areaName);
            }


            Close();

            if (IndicatorCandle != null)
            {
                IndicatorCandle.ShowDialog();
            }
        }