コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public SeparateBalanceChart()
        {
            Text         = Language.T("Balance / Equity Chart");
            Icon         = Data.Icon;
            AcceptButton = BtnClose;

            // Button Close
            BtnClose = new Button
            {
                Parent                  = this,
                Text                    = Language.T("Close"),
                DialogResult            = DialogResult.Cancel,
                UseVisualStyleBackColor = true
            };

            // Balance chart
            BalanceChart = new SmallBalanceChart {
                Parent = this, ShowDynamicInfo = true
            };
            BalanceChart.MouseMove  += BalanceChartMouseMove;
            BalanceChart.MouseLeave += BalanceChartMouseLeave;
            BalanceChart.SetChartData();
            BalanceChart.InitChart();

            // Label Dynamic Info
            LblDynInfo = new Label
            {
                Parent = this, ForeColor = LayoutColors.ColorControlText, BackColor = Color.Transparent
            };
        }
コード例 #2
0
        /// <summary>
        ///     Constructor
        /// </summary>
        public SeparateBalanceChart()
        {
            Text = Language.T("Balance / Equity Chart");
            Icon = Data.Icon;
            AcceptButton = BtnClose;

            // Button Close
            BtnClose = new Button
                {
                    Parent = this,
                    Text = Language.T("Close"),
                    DialogResult = DialogResult.Cancel,
                    UseVisualStyleBackColor = true
                };

            // Balance chart
            BalanceChart = new SmallBalanceChart {Parent = this, ShowDynamicInfo = true};
            BalanceChart.MouseMove += BalanceChartMouseMove;
            BalanceChart.MouseLeave += BalanceChartMouseLeave;
            BalanceChart.SetChartData();
            BalanceChart.InitChart();

            // Label Dynamic Info
            LblDynInfo = new Label
                {Parent = this, ForeColor = LayoutColors.ColorControlText, BackColor = Color.Transparent};
        }
コード例 #3
0
        /// <summary>
        ///     Initializes main controls of optimizer.
        /// </summary>
        private void InitializeControls()
        {
            pnlParamsBase    = new Panel();
            pnlParamsBase2   = new Panel();
            pnlCaptions      = new Panel();
            pnlParams        = new Panel();
            pnlCriteriaBase  = new FancyPanel(Language.T("Acceptance Criteria"));
            criteriaPanel    = new ScrollFlowPanel();
            criteriaControls = new CriteriaControls();
            pnlSettings      = new FancyPanel(Language.T("Settings"));
            scrollBar        = new VScrollBar();
            balanceChart     = new SmallBalanceChart();
            progressBar      = new ProgressBar();
            btnOptimize      = new Button();
            btnAccept        = new Button();
            btnCancel        = new Button();

            lblNoParams = new Label();

            fontIndicator = new Font(Font.FontFamily, 11);
            colorText     = LayoutColors.ColorControlText;

            // Panel Parameters Base
            pnlParamsBase.Parent    = this;
            pnlParamsBase.BackColor = LayoutColors.ColorControlBack;
            pnlParamsBase.Paint    += PnlParamsBasePaint;

            // Panel Captions
            pnlCaptions.Parent    = pnlParamsBase;
            pnlCaptions.Dock      = DockStyle.Top;
            pnlCaptions.BackColor = LayoutColors.ColorCaptionBack;
            pnlCaptions.ForeColor = LayoutColors.ColorCaptionText;
            pnlCaptions.Paint    += PnlCaptionsPaint;

            // Panel Parameters Base 2
            pnlParamsBase2.Parent    = pnlParamsBase;
            pnlParamsBase2.BackColor = LayoutColors.ColorControlBack;
            pnlParamsBase2.Resize   += PnlParamsBase2Resize;

            // ScrollBar
            scrollBar.Parent        = pnlParamsBase2;
            scrollBar.Dock          = DockStyle.Right;
            scrollBar.TabStop       = true;
            scrollBar.ValueChanged += ScrollBarValueChanged;
            scrollBar.MouseWheel   += ScrollBarMouseWheel;

            // Panel Parameters
            pnlParams.Parent    = pnlParamsBase2;
            pnlParams.BackColor = LayoutColors.ColorControlBack;

            // Label No Parameters
            lblNoParams.Parent   = pnlParams;
            lblNoParams.Text     = Language.T("There are no parameters suitable for optimization.");
            lblNoParams.AutoSize = true;
            lblNoParams.Visible  = false;

            // Panel Limitations
            pnlCriteriaBase.Parent  = this;
            pnlCriteriaBase.Visible = false;

            // Panel Settings
            pnlSettings.Parent  = this;
            pnlSettings.Visible = false;

            // Small Balance Chart
            balanceChart.Parent    = this;
            balanceChart.BackColor = LayoutColors.ColorControlBack;
            balanceChart.SetChartData();

            // ProgressBar
            progressBar.Parent  = this;
            progressBar.Minimum = 1;
            progressBar.Maximum = 100;
            progressBar.Step    = 1;

            // Button Optimize
            btnOptimize.Parent   = this;
            btnOptimize.Name     = "btnOptimize";
            btnOptimize.Text     = Language.T("Optimize");
            btnOptimize.TabIndex = 0;
            btnOptimize.Click   += BtnOptimizeClick;
            btnOptimize.UseVisualStyleBackColor = true;

            // Button Accept
            btnAccept.Parent                  = this;
            btnAccept.Name                    = "btnAccept";
            btnAccept.Text                    = Language.T("Accept");
            btnAccept.TabIndex                = 1;
            btnAccept.Enabled                 = false;
            btnAccept.DialogResult            = DialogResult.OK;
            btnAccept.UseVisualStyleBackColor = true;

            // Button Cancel
            btnCancel.Parent                  = this;
            btnCancel.Text                    = Language.T("Cancel");
            btnCancel.TabIndex                = 2;
            btnCancel.DialogResult            = DialogResult.Cancel;
            btnCancel.UseVisualStyleBackColor = true;

            // BackGroundWorker
            bgWorker = new BackgroundWorker {
                WorkerReportsProgress = true, WorkerSupportsCancellation = true
            };
            bgWorker.DoWork             += BgWorkerDoWork;
            bgWorker.ProgressChanged    += BgWorkerProgressChanged;
            bgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;
        }
コード例 #4
0
        /// <summary>
        ///     Constructor
        /// </summary>
        public Generator()
        {
            GeneratedDescription = string.Empty;
            strategyBest = Data.Strategy.Clone();
            bestValue = isOOS ? Backtester.Balance(barOOS) : Backtester.NetBalance;
            isGenerating = false;
            isStartegyChanged = false;
            indicatorBlackList = new List<string>();

            colorText = LayoutColors.ColorControlText;

            toolStrip = new ToolStrip();
            strategyField = new StrategyLayout(strategyBest);
            pnlCommon = new FancyPanel(Language.T("Common"));
            pnlCriteriaBase = new FancyPanel(Language.T("Acceptance Criteria"));
            criteriaPanel = new ScrollFlowPanel();
            criteriaControls = new CriteriaControls();
            pnlSettings = new FancyPanel(Language.T("Settings"));
            pnlSorting = new FancyPanel(Language.T("Custom Sorting"));
            pnlTop10 = new FancyPanel(Language.T("Top 10"));
            pnlIndicators = new FancyPanel(Language.T("Indicators"));
            balanceChart = new SmallBalanceChart();
            infpnlAccountStatistics = new InfoPanel();
            progressBar = new ProgressBar();
            lblCalcStrInfo = new Label();
            lblCalcStrNumb = new Label();
            lblBenchmarkInfo = new Label();
            lblBenchmarkNumb = new Label();
            btnAccept = new Button();
            btnGenerate = new Button();
            btnCancel = new Button();
            chbGenerateNewStrategy = new CheckBox();
            chbPreserveSameDirAction = new CheckBox();
            chbPreserveOppDirAction = new CheckBox();
            chbPreservePermSL = new CheckBox();
            chbPreservePermTP = new CheckBox();
            chbPreserveBreakEven = new CheckBox();
            chbInitialOptimization = new CheckBox();
            nudWorkingMinutes = new NumericUpDown();
            chbWorkingMinutes = new CheckBox();

            MaximizeBox = false;
            Icon = Data.Icon;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            BackColor = LayoutColors.ColorFormBack;
            AcceptButton = btnGenerate;
            Text = Language.T("Strategy Generator") + " - " + Data.Symbol + " " + Data.PeriodString + ", " +
                   Data.Bars + " " + Language.T("bars");
            FormClosing += GeneratorFormClosing;

            // Tool Strip
            toolStrip.Parent = this;
            toolStrip.Dock = DockStyle.Top;
            toolStrip.AutoSize = true;

            // Creates a Strategy Layout
            strategyField.Parent = this;
            strategyField.ShowAddSlotButtons = false;
            strategyField.ShowRemoveSlotButtons = false;
            strategyField.ShowPadlockImg = true;
            strategyField.SlotPropertiesTipText = Language.T("Lock or unlock the slot.");
            strategyField.SlotToolTipText = Language.T("Lock, link, or unlock the slot.");

            pnlCommon.Parent = this;
            pnlCriteriaBase.Parent = this;
            pnlSettings.Parent = this;
            pnlSorting.Parent = this;
            pnlTop10.Parent = this;
            pnlIndicators.Parent = this;

            // Small Balance Chart
            balanceChart.Parent = this;
            balanceChart.BackColor = LayoutColors.ColorControlBack;
            balanceChart.Visible = true;
            balanceChart.Cursor = Cursors.Hand;
            balanceChart.IsContextButtonVisible = true;
            balanceChart.PopUpContextMenu.Items.AddRange(GetBalanceChartContextMenuItems());
            balanceChart.Click += AccountOutputClick;
            balanceChart.DoubleClick += AccountOutputClick;
            toolTip.SetToolTip(balanceChart, Language.T("Show account statistics."));
            balanceChart.SetChartData();

            // Info Panel Account Statistics
            infpnlAccountStatistics.Parent = this;
            infpnlAccountStatistics.Visible = false;
            infpnlAccountStatistics.Cursor = Cursors.Hand;
            infpnlAccountStatistics.IsContextButtonVisible = true;
            infpnlAccountStatistics.PopUpContextMenu.Items.AddRange(GetInfoPanelContextMenuItems());
            infpnlAccountStatistics.Click += AccountOutputClick;
            infpnlAccountStatistics.DoubleClick += AccountOutputClick;
            toolTip.SetToolTip(infpnlAccountStatistics, Language.T("Show account chart."));

            // ProgressBar
            progressBar.Parent = this;
            progressBar.Minimum = 1;
            progressBar.Maximum = 100;
            progressBar.Step = 1;

            //Button Generate
            btnGenerate.Parent = this;
            btnGenerate.Name = "Generate";
            btnGenerate.Text = Language.T("Generate");
            btnGenerate.Click += BtnGenerateClick;
            btnGenerate.UseVisualStyleBackColor = true;

            //Button Accept
            btnAccept.Parent = this;
            btnAccept.Name = "Accept";
            btnAccept.Text = Language.T("Accept");
            btnAccept.Enabled = false;
            btnAccept.DialogResult = DialogResult.OK;
            btnAccept.UseVisualStyleBackColor = true;

            //Button Cancel
            btnCancel.Parent = this;
            btnCancel.Text = Language.T("Cancel");
            btnCancel.DialogResult = DialogResult.Cancel;
            btnCancel.UseVisualStyleBackColor = true;

            // BackgroundWorker
            bgWorker = new BackgroundWorker {WorkerReportsProgress = true, WorkerSupportsCancellation = true};
            bgWorker.DoWork += BgWorkerDoWork;
            bgWorker.ProgressChanged += BgWorkerProgressChanged;
            bgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;

            // Apply a Cryptographic Random Seed
            var rng = new RNGCryptoServiceProvider();
            var rndBytes = new byte[4];
            rng.GetBytes(rndBytes);
            int rand = BitConverter.ToInt32(rndBytes, 0);
            random = new Random(rand);

            SetButtonsStrategy();
            SetButtonsGenerator();
            SetPanelCommon();
            SetCriteriaPanel();
            SetPanelSettings();
            SetPanelSorting();
            SetPanelTop10();
            SetPanelIndicators();
            LoadOptions();
            SetCustomSortingUI();
            SetStrategyDescriptionButton();

            chbHideFsb.CheckedChanged += HideFSBClick;

            if (Data.AutostartGenerator)
                BtnGenerateClick(this, new EventArgs());
        }
コード例 #5
0
        /// <summary>
        /// Initializes main controls of optimizer.
        /// </summary>
        private void InitializeControls()
        {
            PnlParamsBase = new Panel();
            PnlParamsBase2 = new Panel();
            PnlCaptions = new Panel();
            PnlParams = new Panel();
            PnlLimitations = new FancyPanel(Language.T("Limitations"));
            PnlSettings = new FancyPanel(Language.T("Settings"));
            ScrollBar = new VScrollBar();
            BalanceChart = new SmallBalanceChart();
            ProgressBar = new ProgressBar();
            BtnOptimize = new Button();
            BtnAccept = new Button();
            BtnCancel = new Button();

            LblNoParams = new Label();

            _fontIndicator = new Font(Font.FontFamily, 11);
            _colorText = LayoutColors.ColorControlText;

            // Panel Parameters Base
            PnlParamsBase.Parent = this;
            PnlParamsBase.BackColor = LayoutColors.ColorControlBack;
            PnlParamsBase.Paint += PnlParamsBasePaint;

            // Panel Captions
            PnlCaptions.Parent = PnlParamsBase;
            PnlCaptions.Dock = DockStyle.Top;
            PnlCaptions.BackColor = LayoutColors.ColorCaptionBack;
            PnlCaptions.ForeColor = LayoutColors.ColorCaptionText;
            PnlCaptions.Paint += PnlCaptionsPaint;

            // Panel Parameters Base 2
            PnlParamsBase2.Parent = PnlParamsBase;
            PnlParamsBase2.BackColor = LayoutColors.ColorControlBack;
            PnlParamsBase2.Resize += PnlParamsBase2Resize;

            // ScrollBar
            ScrollBar.Parent = PnlParamsBase2;
            ScrollBar.Dock = DockStyle.Right;
            ScrollBar.TabStop = true;
            ScrollBar.ValueChanged += ScrollBarValueChanged;
            ScrollBar.MouseWheel += ScrollBarMouseWheel;

            // Panel Parameters
            PnlParams.Parent = PnlParamsBase2;
            PnlParams.BackColor = LayoutColors.ColorControlBack;

            // Label No Parameters
            LblNoParams.Parent = PnlParams;
            LblNoParams.Text = Language.T("There are no parameters suitable for optimization.");
            LblNoParams.AutoSize = true;
            LblNoParams.Visible = false;

            // Panel Limitations
            PnlLimitations.Parent = this;
            PnlLimitations.Visible = false;

            // Panel Settings
            PnlSettings.Parent = this;
            PnlSettings.Visible = false;

            // Small Balance Chart
            BalanceChart.Parent = this;
            BalanceChart.BackColor = LayoutColors.ColorControlBack;
            BalanceChart.SetChartData();

            // ProgressBar
            ProgressBar.Parent = this;
            ProgressBar.Minimum = 1;
            ProgressBar.Maximum = 100;
            ProgressBar.Step = 1;

            // Button Optimize
            BtnOptimize.Parent = this;
            BtnOptimize.Name = "btnOptimize";
            BtnOptimize.Text = Language.T("Optimize");
            BtnOptimize.TabIndex = 0;
            BtnOptimize.Click += BtnOptimizeClick;
            BtnOptimize.UseVisualStyleBackColor = true;

            // Button Accept
            BtnAccept.Parent = this;
            BtnAccept.Name = "btnAccept";
            BtnAccept.Text = Language.T("Accept");
            BtnAccept.TabIndex = 1;
            BtnAccept.Enabled = false;
            BtnAccept.DialogResult = DialogResult.OK;
            BtnAccept.UseVisualStyleBackColor = true;

            // Button Cancel
            BtnCancel.Parent = this;
            BtnCancel.Text = Language.T("Cancel");
            BtnCancel.TabIndex = 2;
            BtnCancel.DialogResult = DialogResult.Cancel;
            BtnCancel.UseVisualStyleBackColor = true;

            // BackGroundWorker
            BgWorker = new BackgroundWorker {WorkerReportsProgress = true, WorkerSupportsCancellation = true};
            BgWorker.DoWork += BgWorkerDoWork;
            BgWorker.ProgressChanged += BgWorkerProgressChanged;
            BgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;
        }
コード例 #6
0
        /// <summary>
        /// Initializes main controls of optimizer.
        /// </summary>
        private void InitializeControls()
        {
            PnlParamsBase  = new Panel();
            PnlParamsBase2 = new Panel();
            PnlCaptions    = new Panel();
            PnlParams      = new Panel();
            PnlLimitations = new FancyPanel(Language.T("Limitations"));
            PnlSettings    = new FancyPanel(Language.T("Settings"));
            ScrollBar      = new VScrollBar();
            BalanceChart   = new SmallBalanceChart();
            ProgressBar    = new ProgressBar();
            BtnOptimize    = new Button();
            BtnAccept      = new Button();
            BtnCancel      = new Button();

            LblNoParams = new Label();

            _fontIndicator = new Font(Font.FontFamily, 11);
            _colorText     = LayoutColors.ColorControlText;

            // Panel Parameters Base
            PnlParamsBase.Parent    = this;
            PnlParamsBase.BackColor = LayoutColors.ColorControlBack;
            PnlParamsBase.Paint    += PnlParamsBasePaint;

            // Panel Captions
            PnlCaptions.Parent    = PnlParamsBase;
            PnlCaptions.Dock      = DockStyle.Top;
            PnlCaptions.BackColor = LayoutColors.ColorCaptionBack;
            PnlCaptions.ForeColor = LayoutColors.ColorCaptionText;
            PnlCaptions.Paint    += PnlCaptionsPaint;

            // Panel Parameters Base 2
            PnlParamsBase2.Parent    = PnlParamsBase;
            PnlParamsBase2.BackColor = LayoutColors.ColorControlBack;
            PnlParamsBase2.Resize   += PnlParamsBase2Resize;

            // ScrollBar
            ScrollBar.Parent        = PnlParamsBase2;
            ScrollBar.Dock          = DockStyle.Right;
            ScrollBar.TabStop       = true;
            ScrollBar.ValueChanged += ScrollBarValueChanged;
            ScrollBar.MouseWheel   += ScrollBarMouseWheel;

            // Panel Parameters
            PnlParams.Parent    = PnlParamsBase2;
            PnlParams.BackColor = LayoutColors.ColorControlBack;

            // Label No Parameters
            LblNoParams.Parent   = PnlParams;
            LblNoParams.Text     = Language.T("There are no parameters suitable for optimization.");
            LblNoParams.AutoSize = true;
            LblNoParams.Visible  = false;

            // Panel Limitations
            PnlLimitations.Parent  = this;
            PnlLimitations.Visible = false;

            // Panel Settings
            PnlSettings.Parent  = this;
            PnlSettings.Visible = false;

            // Small Balance Chart
            BalanceChart.Parent    = this;
            BalanceChart.BackColor = LayoutColors.ColorControlBack;
            BalanceChart.SetChartData();

            // ProgressBar
            ProgressBar.Parent  = this;
            ProgressBar.Minimum = 1;
            ProgressBar.Maximum = 100;
            ProgressBar.Step    = 1;

            // Button Optimize
            BtnOptimize.Parent   = this;
            BtnOptimize.Name     = "btnOptimize";
            BtnOptimize.Text     = Language.T("Optimize");
            BtnOptimize.TabIndex = 0;
            BtnOptimize.Click   += BtnOptimizeClick;
            BtnOptimize.UseVisualStyleBackColor = true;

            // Button Accept
            BtnAccept.Parent                  = this;
            BtnAccept.Name                    = "btnAccept";
            BtnAccept.Text                    = Language.T("Accept");
            BtnAccept.TabIndex                = 1;
            BtnAccept.Enabled                 = false;
            BtnAccept.DialogResult            = DialogResult.OK;
            BtnAccept.UseVisualStyleBackColor = true;

            // Button Cancel
            BtnCancel.Parent                  = this;
            BtnCancel.Text                    = Language.T("Cancel");
            BtnCancel.TabIndex                = 2;
            BtnCancel.DialogResult            = DialogResult.Cancel;
            BtnCancel.UseVisualStyleBackColor = true;

            // BackGroundWorker
            BgWorker = new BackgroundWorker {
                WorkerReportsProgress = true, WorkerSupportsCancellation = true
            };
            BgWorker.DoWork             += BgWorkerDoWork;
            BgWorker.ProgressChanged    += BgWorkerProgressChanged;
            BgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;
        }
コード例 #7
0
        /// <summary>
        ///     Initializes main controls of optimizer.
        /// </summary>
        private void InitializeControls()
        {
            pnlParamsBase = new Panel();
            pnlParamsBase2 = new Panel();
            pnlCaptions = new Panel();
            pnlParams = new Panel();
            pnlCriteriaBase = new FancyPanel(Language.T("Acceptance Criteria"));
            criteriaPanel = new ScrollFlowPanel();
            criteriaControls = new CriteriaControls();
            pnlSettings = new FancyPanel(Language.T("Settings"));
            scrollBar = new VScrollBar();
            balanceChart = new SmallBalanceChart();
            progressBar = new ProgressBar();
            btnOptimize = new Button();
            btnAccept = new Button();
            btnCancel = new Button();

            lblNoParams = new Label();

            fontIndicator = new Font(Font.FontFamily, 11);
            colorText = LayoutColors.ColorControlText;

            // Panel Parameters Base
            pnlParamsBase.Parent = this;
            pnlParamsBase.BackColor = LayoutColors.ColorControlBack;
            pnlParamsBase.Paint += PnlParamsBasePaint;

            // Panel Captions
            pnlCaptions.Parent = pnlParamsBase;
            pnlCaptions.Dock = DockStyle.Top;
            pnlCaptions.BackColor = LayoutColors.ColorCaptionBack;
            pnlCaptions.ForeColor = LayoutColors.ColorCaptionText;
            pnlCaptions.Paint += PnlCaptionsPaint;

            // Panel Parameters Base 2
            pnlParamsBase2.Parent = pnlParamsBase;
            pnlParamsBase2.BackColor = LayoutColors.ColorControlBack;
            pnlParamsBase2.Resize += PnlParamsBase2Resize;

            // ScrollBar
            scrollBar.Parent = pnlParamsBase2;
            scrollBar.Dock = DockStyle.Right;
            scrollBar.TabStop = true;
            scrollBar.ValueChanged += ScrollBarValueChanged;
            scrollBar.MouseWheel += ScrollBarMouseWheel;

            // Panel Parameters
            pnlParams.Parent = pnlParamsBase2;
            pnlParams.BackColor = LayoutColors.ColorControlBack;

            // Label No Parameters
            lblNoParams.Parent = pnlParams;
            lblNoParams.Text = Language.T("There are no parameters suitable for optimization.");
            lblNoParams.AutoSize = true;
            lblNoParams.Visible = false;

            // Panel Limitations
            pnlCriteriaBase.Parent = this;
            pnlCriteriaBase.Visible = false;

            // Panel Settings
            pnlSettings.Parent = this;
            pnlSettings.Visible = false;

            // Small Balance Chart
            balanceChart.Parent = this;
            balanceChart.BackColor = LayoutColors.ColorControlBack;
            balanceChart.SetChartData();

            // ProgressBar
            progressBar.Parent = this;
            progressBar.Minimum = 1;
            progressBar.Maximum = 100;
            progressBar.Step = 1;

            // Button Optimize
            btnOptimize.Parent = this;
            btnOptimize.Name = "btnOptimize";
            btnOptimize.Text = Language.T("Optimize");
            btnOptimize.TabIndex = 0;
            btnOptimize.Click += BtnOptimizeClick;
            btnOptimize.UseVisualStyleBackColor = true;

            // Button Accept
            btnAccept.Parent = this;
            btnAccept.Name = "btnAccept";
            btnAccept.Text = Language.T("Accept");
            btnAccept.TabIndex = 1;
            btnAccept.Enabled = false;
            btnAccept.DialogResult = DialogResult.OK;
            btnAccept.UseVisualStyleBackColor = true;

            // Button Cancel
            btnCancel.Parent = this;
            btnCancel.Text = Language.T("Cancel");
            btnCancel.TabIndex = 2;
            btnCancel.DialogResult = DialogResult.Cancel;
            btnCancel.UseVisualStyleBackColor = true;

            // BackGroundWorker
            bgWorker = new BackgroundWorker {WorkerReportsProgress = true, WorkerSupportsCancellation = true};
            bgWorker.DoWork += BgWorkerDoWork;
            bgWorker.ProgressChanged += BgWorkerProgressChanged;
            bgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;
        }
コード例 #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Generator()
        {
            GeneratedDescription = string.Empty;
            _strategyBest = Data.Strategy.Clone();
            _bestBalance = _isOOS ? Backtester.Balance(_barOOS) : Backtester.NetBalance;
            _isGenerating = false;
            _isStartegyChanged = false;
            _indicatorBlackList = new List<string>();

            ColorText = LayoutColors.ColorControlText;

            TsStrategy = new ToolStrip();
            TsGenerator = new ToolStrip();
            StrategyField = new StrategyLayout(_strategyBest);
            PnlCommon = new FancyPanel(Language.T("Common"));
            PnlLimitations = new FancyPanel(Language.T("Limitations"));
            PnlSettings = new FancyPanel(Language.T("Settings"));
            PnlTop10 = new FancyPanel(Language.T("Top 10"));
            PnlIndicators = new FancyPanel(Language.T("Indicators"));
            BalanceChart = new SmallBalanceChart();
            InfpnlAccountStatistics = new InfoPanel();
            ProgressBar = new ProgressBar();
            LblCalcStrInfo = new Label();
            LblCalcStrNumb = new Label();
            BtnAccept = new Button();
            BtnGenerate = new Button();
            BtnCancel = new Button();
            ChbGenerateNewStrategy = new CheckBox();
            ChbPreservePermSL = new CheckBox();
            ChbPreservePermTP = new CheckBox();
            ChbPreserveBreakEven = new CheckBox();
            ChbInitialOptimization = new CheckBox();
            NudWorkingMinutes = new NumericUpDown();
            LblWorkingMinutes = new Label();

            MaximizeBox = false;
            Icon = Data.Icon;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            BackColor = LayoutColors.ColorFormBack;
            AcceptButton = BtnGenerate;
            Text = Language.T("Strategy Generator") + " - " + Data.Symbol + " " + Data.PeriodString + ", " +
                   Data.Bars + " " + Language.T("bars");
            FormClosing += GeneratorFormClosing;

            // Tool Strip Strategy
            TsStrategy.Parent = this;
            TsStrategy.Dock = DockStyle.None;
            TsStrategy.AutoSize = false;

            // Tool Strip Generator
            TsGenerator.Parent = this;
            TsGenerator.Dock = DockStyle.None;
            TsGenerator.AutoSize = false;

            // Creates a Strategy Layout
            StrategyField.Parent = this;
            StrategyField.ShowAddSlotButtons = false;
            StrategyField.ShowRemoveSlotButtons = false;
            StrategyField.ShowPadlockImg = true;
            StrategyField.SlotPropertiesTipText = Language.T("Lock or unlock the slot.");
            StrategyField.SlotToolTipText = Language.T("Lock, link, or unlock the slot.");

            PnlCommon.Parent = this;
            PnlLimitations.Parent = this;
            PnlSettings.Parent = this;
            PnlTop10.Parent = this;
            PnlIndicators.Parent = this;

            // Small Balance Chart
            BalanceChart.Parent = this;
            BalanceChart.BackColor = LayoutColors.ColorControlBack;
            BalanceChart.Visible = true;
            BalanceChart.Cursor = Cursors.Hand;
            BalanceChart.IsContextButtonVisible = true;
            BalanceChart.PopUpContextMenu.Items.AddRange(GetBalanceChartContextMenuItems());
            BalanceChart.Click += AccountAutputClick;
            BalanceChart.DoubleClick += AccountAutputClick;
            toolTip.SetToolTip(BalanceChart, Language.T("Show account statistics."));
            BalanceChart.SetChartData();

            // Info Panel Account Statistics
            InfpnlAccountStatistics.Parent = this;
            InfpnlAccountStatistics.Visible = false;
            InfpnlAccountStatistics.Cursor = Cursors.Hand;
            InfpnlAccountStatistics.IsContextButtonVisible = true;
            InfpnlAccountStatistics.PopUpContextMenu.Items.AddRange(GetInfoPanelContextMenuItems());
            InfpnlAccountStatistics.Click += AccountAutputClick;
            InfpnlAccountStatistics.DoubleClick += AccountAutputClick;
            toolTip.SetToolTip(InfpnlAccountStatistics, Language.T("Show account chart."));

            // ProgressBar
            ProgressBar.Parent = this;
            ProgressBar.Minimum = 1;
            ProgressBar.Maximum = 100;
            ProgressBar.Step = 1;

            //Button Generate
            BtnGenerate.Parent = this;
            BtnGenerate.Name = "Generate";
            BtnGenerate.Text = Language.T("Generate");
            BtnGenerate.Click += BtnGenerateClick;
            BtnGenerate.UseVisualStyleBackColor = true;

            //Button Accept
            BtnAccept.Parent = this;
            BtnAccept.Name = "Accept";
            BtnAccept.Text = Language.T("Accept");
            BtnAccept.Enabled = false;
            BtnAccept.DialogResult = DialogResult.OK;
            BtnAccept.UseVisualStyleBackColor = true;

            //Button Cancel
            BtnCancel.Parent = this;
            BtnCancel.Text = Language.T("Cancel");
            BtnCancel.DialogResult = DialogResult.Cancel;
            BtnCancel.UseVisualStyleBackColor = true;

            // BackgroundWorker
            BgWorker = new BackgroundWorker {WorkerReportsProgress = true, WorkerSupportsCancellation = true};
            BgWorker.DoWork += BgWorkerDoWork;
            BgWorker.ProgressChanged += BgWorkerProgressChanged;
            BgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;

            SetButtonsStrategy();
            SetButtonsGenerator();
            SetPanelCommon();
            SetPanelLimitations();
            SetPanelSettings();
            SetPanelTop10();
            SetPanelIndicators();
            LoadOptions();
            SetStrategyDescriptionButton();

            ChbHideFsb.CheckedChanged += HideFSBClick;
        }