SetStrategyIndicators() public static method

Sets the indicator names
public static SetStrategyIndicators ( ) : void
return void
コード例 #1
0
        /// <summary>
        /// View / edit the strategy description
        /// </summary>
        protected virtual void BtnStrategyDescription_Click(object sender, EventArgs e)
        {
            string oldInfo          = Data.Strategy.Description;
            Strategy_Description si = new Strategy_Description();

            si.ShowDialog();
            if (oldInfo != Data.Strategy.Description)
            {
                Data.SetStrategyIndicators();
                SetSrategyDescriptionButton();
                this.Text = Path.GetFileNameWithoutExtension(Data.StrategyName) + "* - " + Data.ProgramName;
                Data.IsStrategyChanged = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Reads the strategy from a file.
        /// </summary>
        /// <returns>0 - success.</returns>
        int OpenStrategy(string strategyFilePath)
        {
            try
            {
                if (File.Exists(strategyFilePath) && Strategy.Load(strategyFilePath))
                {   // Successfully opening
                    Data.Strategy.StrategyName = Path.GetFileNameWithoutExtension(strategyFilePath);
                    Data.StrategyDir           = Path.GetDirectoryName(strategyFilePath);
                    Data.StrategyName          = Path.GetFileName(strategyFilePath);
                    if (Data.Strategy.OpenFilters > Configs.MAX_ENTRY_FILTERS)
                    {
                        Configs.MAX_ENTRY_FILTERS = Data.Strategy.OpenFilters;
                    }
                    if (Data.Strategy.CloseFilters > Configs.MAX_EXIT_FILTERS)
                    {
                        Configs.MAX_EXIT_FILTERS = Data.Strategy.CloseFilters;
                    }
                }
                else
                {
                    Strategy.GenerateNew();
                    string sMessageText = Language.T("The strategy could not be loaded correctly!");
                    MessageBox.Show(sMessageText, Language.T("Strategy Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Data.LoadedSavedStrategy = "";
                    this.Text = Data.ProgramName;
                }

                Data.SetStrategyIndicators();
                RebuildStrategyLayout();

                this.Text = Data.Strategy.StrategyName + " - " + Data.ProgramName;
                Data.IsStrategyChanged   = false;
                Data.LoadedSavedStrategy = Data.StrategyPath;

                Data.StackStrategy.Clear();
            }
            catch
            {
                Strategy.GenerateNew();
                string sMessageText = Language.T("The strategy could not be loaded correctly!");
                MessageBox.Show(sMessageText, Language.T("Strategy Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Data.LoadedSavedStrategy = "";
                this.Text = Data.ProgramName;
                RebuildStrategyLayout();
                return(1);
            }

            return(0);
        }
コード例 #3
0
        /// <summary>
        /// View / edit the strategy description
        /// </summary>
        private void BtnStrategyDescriptionClick(object sender, EventArgs e)
        {
            string oldInfo = Data.Strategy.Description;
            var    si      = new StrategyDescription();

            si.ShowDialog();
            if (oldInfo == Data.Strategy.Description)
            {
                return;
            }
            Data.SetStrategyIndicators();
            SetStrategyDescriptionButton();
            Text = Path.GetFileNameWithoutExtension(Data.StrategyName) + "* - " + Data.ProgramName;
            Data.IsStrategyChanged = true;
        }
コード例 #4
0
        /// <summary>
        /// Pastes a strategy from clipboard.
        /// </summary>
        protected override void MenuStrategyPaste_OnClick(object sender, EventArgs e)
        {
            DialogResult dialogResult = WhetherSaveChangedStrategy();

            if (dialogResult == DialogResult.Yes)
            {
                SaveStrategy();
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            System.Xml.XmlDocument xmlDoc      = new System.Xml.XmlDocument();
            Strategy_XML           strategyXML = new Strategy_XML();
            Strategy tempStrategy;

            try
            {
                xmlDoc.InnerXml = Clipboard.GetText();
                tempStrategy    = strategyXML.ParseXmlStrategy(xmlDoc);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }

            Data.Strategy     = tempStrategy;
            Data.StrategyName = tempStrategy.StrategyName;

            Data.SetStrategyIndicators();
            RebuildStrategyLayout();

            this.Text = Data.Strategy.StrategyName + " - " + Data.ProgramName;
            Data.IsStrategyChanged   = false;
            Data.LoadedSavedStrategy = Data.StrategyPath;
            Data.StackStrategy.Clear();

            AfterStrategyOpening(false);
            Calculate(false);

            return;
        }
コード例 #5
0
        /// <summary>
        ///  Starts the generator
        /// </summary>
        void ShowGenerator()
        {
            // Put the Strategy into the Undo Stack
            Data.StackStrategy.Push(Data.Strategy.Clone());
            Data.IsStrategyReady = false;

            string sOrginalDescription = Data.Strategy.Description;

            Forex_Strategy_Builder.Dialogs.Generator.Generator generator = new Forex_Strategy_Builder.Dialogs.Generator.Generator();
            generator.SetParrentForm = this;
            generator.ShowDialog();

            if (generator.DialogResult == DialogResult.OK)
            {   // We accept the generated strategy
                Data.StrategyName = Data.Strategy.StrategyName + ".xml";
                Text = Data.Strategy.StrategyName + "* - " + Data.ProgramName;

                if (generator.IsStrategyModified)
                {
                    Data.Strategy.Description = (sOrginalDescription != string.Empty ?
                                                 sOrginalDescription + Environment.NewLine + Environment.NewLine +
                                                 "-----------" + Environment.NewLine + generator.GeneratedDescription :
                                                 generator.GeneratedDescription);
                }
                else
                {
                    Data.SetStrategyIndicators();
                    Data.Strategy.Description = generator.GeneratedDescription;
                }
                Data.IsStrategyChanged = true;
                RebuildStrategyLayout();
                Calculate(true);
            }
            else
            {   // When we cancel the Generating, we return the original strategy.
                UndoStrategy();
            }

            Data.IsStrategyReady = true;
            Data.GeneratorStarts++;

            return;
        }