/// <summary>
        /// Adds a strategy to the top 10 Layout
        /// </summary>
        public void AddStrategyInfo(Top10StrategyInfo top10StrategyInfo)
        {
            if (_top10Holder.ContainsKey(top10StrategyInfo.Balance))
            {
                return;
            }

            if (_top10Holder.Count == _maxStrategies && top10StrategyInfo.Balance <= _minBalance)
            {
                return;
            }

            if (_top10Holder.Count == _maxStrategies && top10StrategyInfo.Balance > _minBalance)
            {
                _top10Holder.Remove(_minBalance);
                _top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }
            else if (_top10Holder.Count < _maxStrategies)
            {
                _top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }

            _top10Holder.ReverseSort();

            _minBalance = int.MaxValue;
            _maxBalance = int.MinValue;
            foreach (var keyValue in _top10Holder)
            {
                if (_minBalance > keyValue.Key)
                {
                    _minBalance = keyValue.Key;
                }
                if (_maxBalance < keyValue.Key)
                {
                    _maxBalance = keyValue.Key;
                }
            }

            foreach (var keyValue in _top10Holder)
            {
                keyValue.Value.Top10Slot.IsSelected = false;
            }

            _top10Holder[_maxBalance].Top10Slot.IsSelected = true;

            ArrangeTop10Slots();
            SetVerticalScrollBar();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a strategy to the top 10 Layout
        /// </summary>
        public void AddStrategyInfo(Top10StrategyInfo top10StrategyInfo)
        {
            if (top10Holder.ContainsKey(top10StrategyInfo.Balance))
            {
                return;
            }

            if (top10Holder.Count == maxStrategies && top10StrategyInfo.Balance <= minBalance)
            {
                return;
            }

            if (top10Holder.Count == maxStrategies && top10StrategyInfo.Balance > minBalance)
            {
                top10Holder.Remove(minBalance);
                top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }
            else if (top10Holder.Count < maxStrategies)
            {
                top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }

            top10Holder.ReverseSort();

            minBalance = int.MaxValue;
            maxBalance = int.MinValue;
            foreach (KeyValuePair <int, Top10StrategyInfo> keyValue in top10Holder)
            {
                if (minBalance > keyValue.Key)
                {
                    minBalance = keyValue.Key;
                }
                if (maxBalance < keyValue.Key)
                {
                    maxBalance = keyValue.Key;
                }
            }

            foreach (KeyValuePair <int, Top10StrategyInfo> keyValue in top10Holder)
            {
                keyValue.Value.Top10Slot.IsSelected = false;
            }

            top10Holder[maxBalance].Top10Slot.IsSelected = true;

            ArrangeTop10Slots();
            SetVerticalScrollBar();
        }
        /// <summary>
        /// Adds a strategy to the top 10 Layout
        /// </summary>
        public void AddStrategyInfo(Top10StrategyInfo top10StrategyInfo)
        {
            if (_top10Holder.ContainsKey(top10StrategyInfo.Balance))
                return;

            if (_top10Holder.Count == _maxStrategies && top10StrategyInfo.Balance <= _minBalance)
                return;

            if (_top10Holder.Count == _maxStrategies && top10StrategyInfo.Balance > _minBalance)
            {
                _top10Holder.Remove(_minBalance);
                _top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }
            else if (_top10Holder.Count < _maxStrategies)
            {
                _top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }

            _top10Holder.ReverseSort();

            _minBalance = int.MaxValue;
            _maxBalance = int.MinValue;
            foreach (var keyValue in _top10Holder)
            {
                if (_minBalance > keyValue.Key)
                    _minBalance = keyValue.Key;
                if (_maxBalance < keyValue.Key)
                    _maxBalance = keyValue.Key;
            }

            foreach (var keyValue in _top10Holder)
                keyValue.Value.Top10Slot.IsSelected = false;

            _top10Holder[_maxBalance].Top10Slot.IsSelected = true;

            ArrangeTop10Slots();
            SetVerticalScrollBar();
        }
        /// <summary>
        /// Adds a strategy to the top 10 Layout
        /// </summary>
        public void AddStrategyInfo(Top10StrategyInfo top10StrategyInfo)
        {
            if (top10Holder.ContainsKey(top10StrategyInfo.Balance))
            {
                return;
            }

            if(top10Holder.Count == maxStrategies && top10StrategyInfo.Balance <= minBalance)
                return;

            if (top10Holder.Count == maxStrategies && top10StrategyInfo.Balance > minBalance)
            {
                top10Holder.Remove(minBalance);
                top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);
            }
            else if (top10Holder.Count < maxStrategies)
                top10Holder.Add(top10StrategyInfo.Balance, top10StrategyInfo);

            top10Holder.ReverseSort();

            minBalance = int.MaxValue;
            maxBalance = int.MinValue;
            foreach (KeyValuePair<int, Top10StrategyInfo> keyValue in top10Holder)
            {
                if (minBalance > keyValue.Key)
                    minBalance = keyValue.Key;
                if (maxBalance < keyValue.Key)
                    maxBalance = keyValue.Key;
            }

            foreach (KeyValuePair<int, Top10StrategyInfo> keyValue in top10Holder)
                    keyValue.Value.Top10Slot.IsSelected = false;

            top10Holder[maxBalance].Top10Slot.IsSelected = true;

            ArrangeTop10Slots();
            SetVerticalScrollBar();
        }
 /// <summary>
 /// Adds a strategy to Top 10 list.
 /// </summary>
 void Top10AddStrategy()
 {
     if (top10Layout.InvokeRequired)
     {
         Invoke(new DelegateTop10AddStrategy(Top10AddStrategy), new object[] { });
     }
     else
     {
         Top10Slot top10Slot = new Top10Slot();
         top10Slot.Width  = 290;
         top10Slot.Height = 65;
         top10Slot.InitSlot();
         top10Slot.Click       += new EventHandler(Top10Slot_Click);
         top10Slot.DoubleClick += new EventHandler(Top10Slot_Click);
         Top10StrategyInfo top10StrategyInfo = new Top10StrategyInfo();
         top10StrategyInfo.Balance     = Configs.AccountInMoney ? (int)Math.Round(Backtester.NetMoneyBalance) : Backtester.NetBalance;
         top10StrategyInfo.Top10Slot   = top10Slot;
         top10StrategyInfo.TheStrategy = Data.Strategy.Clone();
         top10Layout.AddStrategyInfo(top10StrategyInfo);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Adds a strategy to Top 10 list.
 /// </summary>
 private void Top10AddStrategy()
 {
     if (Top10Field.InvokeRequired)
     {
         Invoke(new DelegateTop10AddStrategy(Top10AddStrategy), new object[] {});
     }
     else
     {
         var top10Slot = new Top10Slot {Width = 290, Height = 65};
         top10Slot.InitSlot();
         top10Slot.Click += Top10SlotClick;
         top10Slot.DoubleClick += Top10SlotClick;
         var top10StrategyInfo = new Top10StrategyInfo
                                     {
                                         Balance = Configs.AccountInMoney
                                                       ? (int) Math.Round(Backtester.NetMoneyBalance)
                                                       : Backtester.NetBalance,
                                         Top10Slot = top10Slot,
                                         TheStrategy = Data.Strategy.Clone()
                                     };
         Top10Field.AddStrategyInfo(top10StrategyInfo);
     }
 }