public override string ActivateScript(CandleChartControl chart, PointD worldCoords) { var comment = chart.seriesComment.data.FirstOrDefault(c => c.Name == CommentSpecName); // удалить существующий if (comment != null) { chart.seriesComment.data.Remove(comment); chart.RedrawChartSafe(); return(string.Empty); } // добавить новый MarketOrder sumPos; string scriptText; GetCommentText(chart, out scriptText, out sumPos); if (sumPos == null) { return(string.Empty); } var colorFill = sumPos.ResultDepo > 0 ? Color.LightGreen : sumPos.ResultDepo < 0 ? Color.LightCoral : Color.Gray; var colorText = chart.chart.BackColor.GetBrightness() < 0.4f ? Color.White : Color.Black; comment = new ChartComment { FillTransparency = 80, ColorFill = colorFill, HideArrow = true, ArrowAngle = 90, ArrowLength = 1, PivotIndex = worldCoords.X, PivotPrice = worldCoords.Y, Owner = chart.seriesComment, Name = CommentSpecName, Text = scriptText, ColorText = colorText, Color = colorText }; chart.seriesComment.data.Add(comment); chart.RedrawChartSafe(); return(string.Empty); }
public override string ActivateScript(CandleChartControl chart, PointD worldCoords) { var robots = MainForm.Instance.RobotFarm.GetRobotsAsIs().ToList(); var commentText = GetCommentForChart(chart.Symbol, chart.Timeframe, robots); if (string.IsNullOrEmpty(commentText)) { return("Нет роботов для " + chart.Symbol + " " + BarSettingsStorage.Instance.GetBarSettingsFriendlyName(chart.Timeframe)); } // разместить комментарий на графике в указанной точке, удалить такой же, если был добавлен var comment = chart.seriesComment.data.FirstOrDefault(c => c.Name == CommentSpecName); if (comment != null) { chart.seriesComment.data.Remove(comment); chart.RedrawChartSafe(); return(string.Empty); } var colorFill = Color.LightGreen; var colorText = chart.chart.BackColor.GetBrightness() < 0.4f ? Color.White : Color.Black; comment = new ChartComment { FillTransparency = 80, ColorFill = colorFill, HideArrow = true, ArrowAngle = 90, ArrowLength = 1, PivotIndex = worldCoords.X, PivotPrice = worldCoords.Y, Owner = chart.seriesComment, Name = CommentSpecName, Text = commentText, ColorText = colorText, Color = colorText }; chart.seriesComment.data.Add(comment); chart.RedrawChartSafe(); return(string.Empty); }
public override string ActivateScript(CandleChartControl chart, PointD worldCoords) { chartSymbol = chart.Symbol; var comment = chart .seriesComment .data .FirstOrDefault(c => c.Name == CommentSpecName); // удалить существующий if (comment != null) { chart.seriesComment.data.Remove(comment); chart.RedrawChartSafe(); return(string.Empty); } var accountData = AccountStatus.Instance.AccountData; var accountStatistics = TradeSharpAccountStatistics.Instance.proxy.GetAccountProfit1000(accountData.ID); var ordersBySymbol = GetMarketOrders(accountData.ID).Where(x => x.Symbol == chart.Symbol); var scriptText = GetCommentText(accountData, accountStatistics, ordersBySymbol); comment = new ChartComment { FillTransparency = 80, ColorFill = Color.Gray, HideArrow = true, ArrowAngle = 90, ArrowLength = 1, PivotIndex = worldCoords.X, PivotPrice = worldCoords.Y, Owner = chart.seriesComment, Name = CommentSpecName, Text = scriptText, ColorText = Color.Black, Color = Color.Black }; chart.seriesComment.data.Add(comment); chart.RedrawChartSafe(); return(string.Empty); }