/// <summary> /// Adds a strategy to the top 10 Layout /// </summary> public void AddStrategyInfo(Top10StrategyInfo strategyInfo) { if (top10Holder.ContainsKey(strategyInfo.Value)) { return; } if (top10Holder.Count == maxStrategies && strategyInfo.Value <= minValue) { return; } if (top10Holder.Count == maxStrategies && strategyInfo.Value > minValue) { top10Holder.Remove(minValue); top10Holder.Add(strategyInfo.Value, strategyInfo); } else if (top10Holder.Count < maxStrategies) { top10Holder.Add(strategyInfo.Value, strategyInfo); } top10Holder.ReverseSort(); minValue = float.MaxValue; maxValue = float.MinValue; foreach (var keyValue in top10Holder) { if (minValue > keyValue.Key) { minValue = keyValue.Key; } if (maxValue < keyValue.Key) { maxValue = keyValue.Key; } } foreach (var keyValue in top10Holder) { keyValue.Value.Top10Slot.IsSelected = false; } top10Holder[maxValue].Top10Slot.IsSelected = true; ArrangeTop10Slots(); SetVerticalScrollBar(); }
/// <summary> /// Adds a strategy to the top 10 Layout /// </summary> public void AddStrategyInfo(Top10StrategyInfo strategyInfo) { if (top10Holder.ContainsKey(strategyInfo.Value)) return; if (top10Holder.Count == maxStrategies && strategyInfo.Value <= minValue) return; if (top10Holder.Count == maxStrategies && strategyInfo.Value > minValue) { top10Holder.Remove(minValue); top10Holder.Add(strategyInfo.Value, strategyInfo); } else if (top10Holder.Count < maxStrategies) { top10Holder.Add(strategyInfo.Value, strategyInfo); } top10Holder.ReverseSort(); minValue = float.MaxValue; maxValue = float.MinValue; foreach (var keyValue in top10Holder) { if (minValue > keyValue.Key) minValue = keyValue.Key; if (maxValue < keyValue.Key) maxValue = keyValue.Key; } foreach (var keyValue in top10Holder) keyValue.Value.Top10Slot.IsSelected = false; top10Holder[maxValue].Top10Slot.IsSelected = true; ArrangeTop10Slots(); SetVerticalScrollBar(); }
/// <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.CustomSortingOption = customSortingOptionDisplay; top10Slot.CustomSortingValue = bestValue; top10Slot.Click += Top10SlotClick; top10Slot.DoubleClick += Top10SlotClick; int balance = Configs.AccountInMoney ? (int) Math.Round(Backtester.NetMoneyBalance) : Backtester.NetBalance; var top10StrategyInfo = new Top10StrategyInfo { Balance = balance, Value = String.IsNullOrEmpty(top10Slot.CustomSortingOption) ? balance : bestValue, Top10Slot = top10Slot, TheStrategy = Data.Strategy.Clone() }; top10Field.AddStrategyInfo(top10StrategyInfo); } }