public override string ActivateScript(CandleChartControl chart, PointD worldCoords)
        {
            this.chart = chart;
            scriptActivatedCoords = worldCoords;

            // найти робота / роботов на данный тикер / ТФ
            var robots = MainForm.Instance.RobotFarm.GetRobotCopies();
            robots = robots.Where(r => r.Graphics.Any(g => g.a == chart.chart.Symbol && g.b == chart.chart.Timeframe))
                      .ToList();
            if (robots.Count == 0) return "Нет роботов для " + chart.Symbol + ":" + chart.Timeframe;
            selectedBot = robots[0];
            // если роботов несколько - предложить пользователю выбрать интересующего
            if (robots.Count > 1)
            {
                object selectedRobot;
                string inputText;

                if (!Dialogs.ShowComboDialog("Укажите робота",
                                                             robots.Cast<object>().ToList(), out selectedRobot,
                                                             out inputText))
                    return "робот не выбран из списка";
                selectedBot = (BaseRobot) selectedRobot;
            }

            ShowRobotDataOnChart();

            return "";
        }
Beispiel #2
0
 /// <summary>
 /// робот, переданный в параметре, получит копию настроек робота this
 /// </summary>
 protected void CopyBaseSettings(BaseRobot dest)
 {
     dest.TypeName     = TypeName;
     dest.Magic        = Magic;
     dest.Leverage     = Leverage;
     dest.FixedVolume  = FixedVolume;
     dest.tickers      = tickers.Select(t => new Cortege2 <string, BarSettings>(t.a, new BarSettings(t.b))).ToList();
     dest.NewsChannels = NewsChannels;
 }
Beispiel #3
0
 protected BaseRobot(BaseRobot robot) : this()
 {
     Magic        = robot.Magic;
     TypeName     = robot.TypeName;
     Leverage     = robot.Leverage;
     FixedVolume  = robot.FixedVolume;
     Graphics     = robot.Graphics;
     NewsChannels = robot.NewsChannels;
 }
Beispiel #4
0
 protected BaseRobot(BaseRobot robot)
     : this()
 {
     Magic = robot.Magic;
     TypeName = robot.TypeName;
     Leverage = robot.Leverage;
     FixedVolume = robot.FixedVolume;
     Graphics = robot.Graphics;
     NewsChannels = robot.NewsChannels;
 }
        public void ShowRobotHintsSafe(BaseRobot robot, List<RobotMark> hints)
        {
            foreach (var hint in hints)
            {
                // определить тикер и таймфрейм
                var ticker = hint.Symbol;
                var timeframe = BarSettingsStorage.Instance.GetBarSettingsByName(hint.Timeframe);

                if (string.IsNullOrEmpty(ticker) && robot.Graphics.Count > 0)
                    ticker = robot.Graphics[0].a;

                if (timeframe == null && robot.Graphics.Count > 0)
                    timeframe = robot.Graphics[0].b;

                if (string.IsNullOrEmpty(ticker)) continue;

                // отыскать график
                foreach (var chart in Charts.Where(c => c.chart.Symbol == ticker && (
                    timeframe == null || c.chart.Timeframe == timeframe)))
                {
                    AddOrRemoveRobotHintOnChart(hint, chart);
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// робот, переданный в параметре, получит копию настроек робота this
 /// </summary>
 protected void CopyBaseSettings(BaseRobot dest)
 {
     dest.TypeName = TypeName;
     dest.Magic = Magic;
     dest.Leverage = Leverage;
     dest.FixedVolume = FixedVolume;
     dest.tickers = tickers.Select(t => new Cortege2<string, BarSettings>(t.a, new BarSettings(t.b))).ToList();
     dest.NewsChannels = NewsChannels;
 }
 public RobotGridItem(BaseRobot robot, bool initialized)
 {
     Robot = robot;
     Initialized = initialized;
 }
 public RobotGridItem(BaseRobot robot)
 {
     Robot = robot;
 }
 /// <summary>
 /// настроить киборгов
 /// </summary>
 private void ShowRobotParamsDialog(BaseRobot robot)
 {
     var chgRobots = robot == null
                         ? grid.GetBoundValuesFromSelectedRows().Select(r => r.Robot).ToArray()
                         : new [] {robot};
     if (chgRobots.Length == 0) return;
     var dlg = GetRobotPropertiesForm(chgRobots.ToList());
     if (chgRobots.Length == 1)
         dlg.Text = Localizer.GetString("TitleSettings") + " " + chgRobots[0].TypeName;
     if (dlg.ShowDialog() != DialogResult.OK)
         return;
     gridRobot.DataBind(grid.GetBoundValues().ToList());
     gridRobot.Invalidate();
 }
Beispiel #10
0
 public void UnsubscribeRobot(BaseRobot robot)
 {
     if (listRobots.IndexOf(robot) != -1)
         listRobots.Remove(robot);
 }
Beispiel #11
0
 public void SubscribeRobot(BaseRobot robot)
 {
     if (listRobots.IndexOf(robot) == -1)
         listRobots.Add(robot);
 }
 public RobotLogEntry(BaseRobot robot, DateTime time, List<string> messages)
 {
     Robot = robot;
     Time = time;
     Messages = messages;
 }
 private void LogRobotMessages(BaseRobot robot, DateTime time, List<string> messages)
 {
     robotLogEntries.Add(new RobotLogEntry(robot, time, messages));
 }
Beispiel #14
0
 private static void ShowRobotEventsSafe(BaseRobot robot, List<string> robotEvents)
 {
     var hints = new List<RobotMark>();
     foreach (var eventStr in robotEvents)
     {
         var hint = RobotMark.ParseString(eventStr);
         if (hint != null) hints.Add(hint);
         else
             MainForm.Instance.ProcessRobotMessage(DateTime.Now, eventStr);
     }
     if (hints.Count == 0) return;
     // показать хинты на графике
     MainForm.Instance.ShowRobotHintsSafe(robot, hints);
 }
 public RobotChartBinding(BaseRobot robot)
 {
     Robot = robot.TypeName;
     RobotCharts = robot.HumanRTickers;
     SelectedCharts = EmptyChartsPlaceholder;
 }