Ejemplo n.º 1
0
        public Condition(IEnumerable <string> cells, IEnumerable <int> symbols)
        {
            Cells   = cells.ToList();
            Symbols = symbols.ToList();

            if (Cells.Count() != Symbols.Count())
            {
                throw new ArgumentException("Invalid condition, cell count does not match symbol count");
            }
        }
        public override void OnStart()
        {
            if (Symbols.Count() > 1)
            {
                throw new InvalidOperationException("This robot is only for single symbol use, not multi symbol");
            }

            _fastMa = new SimpleMovingAverage(Symbols.First())
            {
                DataSourceType = DataSourceType.Close, Periods = FastMaPeriod
            };

            _slowMa = new SimpleMovingAverage(Symbols.First())
            {
                DataSourceType = DataSourceType.Close, Periods = SlowMaPeriod
            };
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load settings from file.
        /// </summary>
        /// <returns>true if settings were loaded, false if they were not.</returns>
        private bool Load()
        {
            string text = Properties.Settings.Default[_settingName] as string;

            if (String.IsNullOrWhiteSpace(text))
            {
                return(false);
            }
            else
            {
                try
                {
                    using (StringReader reader = new StringReader(text))
                    {
                        using (XmlReader xml = XmlReader.Create(reader))
                        {
                            if (!xml.ReadToDescendant("settings"))
                            {
                                throw new Exception("settings element is missing.");
                            }

                            xml.Read();
                            while (xml.NodeType == XmlNodeType.Element)
                            {
                                switch (xml.LocalName)
                                {
                                case "header":
                                    Header = xml.ReadElementContentAsString();
                                    break;

                                case "font":
                                    if (xml["family"] != null)
                                    {
                                        FontFamily = new FontFamily(xml["family"]);
                                    }
                                    if (xml["size"] != null)
                                    {
                                        FontSizeInPoints = double.Parse(xml["size"]);
                                    }
                                    if (xml["foreground"] != null)
                                    {
                                        Foreground = (Color)ColorConverter.ConvertFromString(xml["foreground"]);
                                    }
                                    if (xml["background"] != null)
                                    {
                                        Background = (Color)ColorConverter.ConvertFromString(xml["background"]);
                                    }
                                    if (xml["selectionForeground"] != null)
                                    {
                                        SelectionForeground = (Color)ColorConverter.ConvertFromString(xml["selectionForeground"]);
                                    }
                                    else
                                    {
                                        SelectionForeground = null;
                                    }
                                    if (xml["selectionBackground"] != null)
                                    {
                                        SelectionBackground = (Color)ColorConverter.ConvertFromString(xml["selectionBackground"]);
                                    }
                                    else
                                    {
                                        SelectionBackground = null;
                                    }
                                    if (xml["findResultBackground"] != null)
                                    {
                                        FindResultBackground = (Color)ColorConverter.ConvertFromString(xml["findResultBackground"]);
                                    }
                                    xml.Read();
                                    break;

                                case "symbols":
                                    List <EditorSymbolSettings> symbols = new List <EditorSymbolSettings>();
                                    xml.Read();
                                    while (xml.NodeType == XmlNodeType.Element)
                                    {
                                        EditorSymbolSettings ess = new EditorSymbolSettings();
                                        ess.ReadXml(xml);
                                        symbols.Add(ess);
                                    }
                                    Symbols = symbols;
                                    xml.Read();
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }

                    if (Symbols.Count() == 0)
                    {
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }

                return(true);
            }
        }