Exemple #1
0
        private bool LoadStrategy(string strategyFile)
        {
            var composition = LoadComposition(strategyFile);

            if (composition == null)
            {
                new MessageBoxBuilder()
                .Error()
                .Text(LocalizedStrings.StrategyLoadingCancelled)
                .Owner(this)
                .Button(MessageBoxButton.OK)
                .Show();

                return(false);
            }

            _strategy = new DiagramStrategyEx
            {
                Connector   = _connector,
                Composition = composition,
            };

            _strategy.OrderRegistering    += OnStrategyOrderRegistering;
            _strategy.OrderReRegistering  += OnStrategyOrderReRegistering;
            _strategy.OrderRegisterFailed += OnStrategyOrderRegisterFailed;

            _strategy.StopOrderRegistering    += OnStrategyOrderRegistering;
            _strategy.StopOrderReRegistering  += OnStrategyOrderReRegistering;
            _strategy.StopOrderRegisterFailed += OnStrategyOrderRegisterFailed;

            _strategy.NewMyTrades += OnStrategyNewMyTrade;

            _strategy.PositionManager.NewPosition += OnStrategyNewPosition;
            _strategy.PositionManager.Positions.ForEach(OnStrategyNewPosition);

            _strategy.PnLChanged += OnStrategyPnLChanged;
            _strategy.Reseted    += OnStrategyReseted;

            _strategy.SetCandleManager(new CandleManager(_connector));
            _strategy.SetChart(ChartPanel);

            PropertyGrid.SelectedObject             = _strategy;
            StatisticParameterGrid.StatisticManager = _strategy.StatisticManager;

            return(true);
        }
		private bool LoadStrategy(string strategyFile)
		{
			var composition = LoadComposition(strategyFile);

			if (composition == null)
			{
				new MessageBoxBuilder()
					.Error()
					.Text(LocalizedStrings.StrategyLoadingCancelled)
					.Owner(this)
					.Button(MessageBoxButton.OK)
					.Show();

				return false;
			}

			_strategy = new DiagramStrategyEx
			{
				Connector = _connector,
				Composition = composition,
			};

			_strategy.OrderRegistering += OnStrategyOrderRegistering;
			_strategy.OrderReRegistering += OnStrategyOrderReRegistering;
			_strategy.OrderRegisterFailed += OnStrategyOrderRegisterFailed;

			_strategy.StopOrderRegistering += OnStrategyOrderRegistering;
			_strategy.StopOrderReRegistering += OnStrategyOrderReRegistering;
			_strategy.StopOrderRegisterFailed += OnStrategyOrderRegisterFailed;

			_strategy.NewMyTrades += OnStrategyNewMyTrade;

			_strategy.PositionManager.NewPosition += OnStrategyNewPosition;
			_strategy.PositionManager.Positions.ForEach(OnStrategyNewPosition);

			_strategy.PnLChanged += OnStrategyPnLChanged;
			_strategy.Reseted += OnStrategyReseted;

			_strategy.SetCandleManager(new CandleManager(_connector));
			_strategy.SetChart(ChartPanel);

			PropertyGrid.SelectedObject = _strategy;
			StatisticParameterGrid.StatisticManager = _strategy.StatisticManager;

			return true;
		}