Draws a small balance chart
Inheritance: System.Windows.Forms.Panel
        /// <summary>
        /// Show the dynamic info on the status bar
        /// </summary>
        void SmallBalanceChart_MouseMove(object sender, MouseEventArgs e)
        {
            Small_Balance_Chart chart = (Small_Balance_Chart)sender;

            ToolStripStatusLabelChartInfo = chart.CurrentBarInfo;

            return;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public Optimizer()
        {
            pnlParamsBase     = new Panel();
            pnlParamsBase2    = new Panel();
            pnlCaptions       = new Panel();
            pnlParams         = new Panel();
            pnlLimitations    = new Fancy_Panel(Language.T("Limitations"));
            scrollBar         = new VScrollBar();
            smallBalanceChart = new Small_Balance_Chart();
            progressBar       = new ProgressBar();
            btnOptimize       = new Button();
            btnAccept         = new Button();
            btnCancel         = new Button();

            btnShowLimitations = new Button();
            btnShowSettings    = new Button();

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

            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            Icon            = Data.Icon;
            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            AcceptButton    = btnAccept;
            CancelButton    = btnCancel;
            Text            = Language.T("Optimizer");
            FormClosing    += new FormClosingEventHandler(Optimizer_FormClosing);

            // pnlParamsBase
            pnlParamsBase.Parent    = this;
            pnlParamsBase.BackColor = LayoutColors.ColorControlBack;
            pnlParamsBase.Paint    += new PaintEventHandler(PnlParamsBase_Paint);

            // pnlCaptions
            pnlCaptions.Parent    = pnlParamsBase;
            pnlCaptions.Dock      = DockStyle.Top;
            pnlCaptions.BackColor = LayoutColors.ColorCaptionBack;
            pnlCaptions.ForeColor = LayoutColors.ColorCaptionText;
            pnlCaptions.Paint    += new PaintEventHandler(PnlCaptions_Paint);

            // pnlParamsBase2
            pnlParamsBase2.Parent    = pnlParamsBase;
            pnlParamsBase2.BackColor = LayoutColors.ColorControlBack;
            pnlParamsBase2.Resize   += new EventHandler(PnlParamsBase2_Resize);

            // VScrollBar
            scrollBar.Parent        = pnlParamsBase2;
            scrollBar.Dock          = DockStyle.Right;
            scrollBar.TabStop       = true;
            scrollBar.ValueChanged += new EventHandler(ScrollBar_ValueChanged);
            scrollBar.MouseWheel   += new MouseEventHandler(ScrollBar_MouseWheel);

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

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

            // smallBalanceChart
            smallBalanceChart.Parent    = this;
            smallBalanceChart.BackColor = LayoutColors.ColorControlBack;

            // 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   += new EventHandler(BtnOptimize_Click);
            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;

            chbOutOfSample = new CheckBox();
            chbOutOfSample.Parent    = this;
            chbOutOfSample.ForeColor = colorText;
            chbOutOfSample.BackColor = Color.Transparent;
            chbOutOfSample.Text      = Language.T("OOS");
            chbOutOfSample.Checked   = false;
            chbOutOfSample.AutoSize  = true;
            chbOutOfSample.CheckedChanged += new EventHandler(ChbOutOfSample_CheckedChanged);

            nudOutOfSample = new NumericUpDown();
            nudOutOfSample.Parent    = this;
            nudOutOfSample.TextAlign = HorizontalAlignment.Center;
            nudOutOfSample.BeginInit();
            nudOutOfSample.Minimum   = 10;
            nudOutOfSample.Maximum   = 60;
            nudOutOfSample.Increment = 1;
            nudOutOfSample.Value     = 30;
            nudOutOfSample.EndInit();
            nudOutOfSample.ValueChanged += new EventHandler(NudOutOfSample_ValueChanged);

            // BackGroundWorker
            bgWorker = new BackgroundWorker();
            bgWorker.WorkerReportsProgress      = true;
            bgWorker.WorkerSupportsCancellation = true;
            bgWorker.DoWork             += new DoWorkEventHandler(BgWorker_DoWork);
            bgWorker.ProgressChanged    += new ProgressChangedEventHandler(BgWorker_ProgressChanged);
            bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BgWorker_RunWorkerCompleted);

            isOptimizing = false;
            SetPanelLimitations();

            return;
        }
Exemple #3
0
        public Strategy_Properties()
        {
            pnlAveraging         = new Fancy_Panel(Language.T("Handling of Additional Entry Signals"), LayoutColors.ColorSlotCaptionBackAveraging);
            pnlAmounts           = new Fancy_Panel(Language.T("Trading Size"), LayoutColors.ColorSlotCaptionBackAveraging);
            pnlProtection        = new Fancy_Panel(Language.T("Permanent Protection"), LayoutColors.ColorSlotCaptionBackAveraging);
            pnlSmallBalanceChart = new Small_Balance_Chart();

            lblPercent1 = new Label();
            lblPercent2 = new Label();
            lblPercent3 = new Label();

            lblSameDirAction = new Label();
            lblOppDirAction  = new Label();

            cbxSameDirAction = new ComboBox();
            cbxOppDirAction  = new ComboBox();
            nudMaxOpenLots   = new NUD();
            rbConstantUnits  = new RadioButton();
            rbVariableUnits  = new RadioButton();
            nudEntryLots     = new NUD();
            nudAddingLots    = new NUD();
            nudReducingLots  = new NUD();
            lblMaxOpenLots   = new Label();
            lblEntryLots     = new Label();
            lblAddingLots    = new Label();
            lblReducingLots  = new Label();

            chbPermaSL     = new CheckBox();
            cbxPermaSLType = new ComboBox();
            nudPermaSL     = new NUD();
            chbPermaTP     = new CheckBox();
            cbxPermaTPType = new ComboBox();
            nudPermaTP     = new NUD();

            btnAccept  = new Button();
            btnDefault = new Button();
            btnCancel  = new Button();

            font      = this.Font;
            colorText = LayoutColors.ColorControlText;

            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            Icon            = Data.Icon;
            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            AcceptButton    = btnAccept;
            Text            = Language.T("Strategy Properties");

            pnlAveraging.Parent         = this;
            pnlAmounts.Parent           = this;
            pnlProtection.Parent        = this;
            pnlSmallBalanceChart.Parent = this;
            pnlSmallBalanceChart.SetChartData();

            // Label Same dir action
            lblSameDirAction.Parent    = pnlAveraging;
            lblSameDirAction.ForeColor = colorText;
            lblSameDirAction.BackColor = Color.Transparent;
            lblSameDirAction.AutoSize  = true;
            lblSameDirAction.Text      = Language.T("Next same direction signal behavior");

            // Label Opposite dir action
            lblOppDirAction.Parent    = pnlAveraging;
            lblOppDirAction.ForeColor = colorText;
            lblOppDirAction.BackColor = Color.Transparent;
            lblOppDirAction.AutoSize  = true;
            lblOppDirAction.Text      = Language.T("Next opposite direction signal behavior");

            // ComboBox SameDirAction
            cbxSameDirAction.Parent        = pnlAveraging;
            cbxSameDirAction.Name          = "cbxSameDirAction";
            cbxSameDirAction.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxSameDirAction.Items.AddRange(new string[] { Language.T("Nothing"), Language.T("Winner"), Language.T("Add") });
            cbxSameDirAction.SelectedIndex = 0;
            toolTip.SetToolTip(cbxSameDirAction,
                               Language.T("Nothing - cancels the additional orders.") + Environment.NewLine +
                               Language.T("Winner - adds to a winning position.") + Environment.NewLine +
                               Language.T("Add - adds to all positions."));

            // ComboBox OppDirAction
            cbxOppDirAction.Parent        = pnlAveraging;
            cbxOppDirAction.Name          = "cbxOppDirAction";
            cbxOppDirAction.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxOppDirAction.Items.AddRange(new string[] { Language.T("Nothing"), Language.T("Reduce"), Language.T("Close"), Language.T("Reverse") });
            cbxOppDirAction.SelectedIndex = 0;
            toolTip.SetToolTip(cbxOppDirAction,
                               Language.T("Nothing - cancels the additional orders.") + Environment.NewLine +
                               Language.T("Reduce - reduces or closes a position.") + Environment.NewLine +
                               Language.T("Close - closes the position.") + Environment.NewLine +
                               Language.T("Reverse - reverses the position."));

            // Label MaxOpen Lots
            lblMaxOpenLots.Parent    = pnlAmounts;
            lblMaxOpenLots.ForeColor = colorText;
            lblMaxOpenLots.BackColor = Color.Transparent;
            lblMaxOpenLots.AutoSize  = true;
            lblMaxOpenLots.Text      = Language.T("Maximum number of open lots");

            // NumericUpDown MaxOpen Lots
            nudMaxOpenLots.Parent = pnlAmounts;
            nudMaxOpenLots.Name   = "nudMaxOpenLots";
            nudMaxOpenLots.BeginInit();
            nudMaxOpenLots.Minimum       = 0.01M;
            nudMaxOpenLots.Maximum       = 100;
            nudMaxOpenLots.Increment     = 0.01M;
            nudMaxOpenLots.Value         = 20;
            nudMaxOpenLots.DecimalPlaces = 2;
            nudMaxOpenLots.TextAlign     = HorizontalAlignment.Center;
            nudMaxOpenLots.EndInit();

            // Radio Button Constant Units
            rbConstantUnits.Parent    = pnlAmounts;
            rbConstantUnits.ForeColor = colorText;
            rbConstantUnits.BackColor = Color.Transparent;
            rbConstantUnits.Checked   = true;
            rbConstantUnits.AutoSize  = true;
            rbConstantUnits.Name      = "rbConstantUnits";
            rbConstantUnits.Text      = Language.T("Trade a constant number of lots");

            // Radio Button Variable Units
            rbVariableUnits.Parent    = pnlAmounts;
            rbVariableUnits.ForeColor = colorText;
            rbVariableUnits.BackColor = Color.Transparent;
            rbVariableUnits.Checked   = false;
            rbVariableUnits.AutoSize  = false;
            rbVariableUnits.Name      = "rbVariableUnits";
            rbVariableUnits.Text      = Language.T("Trade percent of your account. The percentage values show the part of the account equity used to cover the required margin.");

            // Label Entry Lots
            lblEntryLots.Parent    = pnlAmounts;
            lblEntryLots.ForeColor = colorText;
            lblEntryLots.BackColor = Color.Transparent;
            lblEntryLots.AutoSize  = true;
            lblEntryLots.Text      = Language.T("Number of entry lots for a new position");

            // NumericUpDown Entry Lots
            nudEntryLots.Parent = pnlAmounts;
            nudEntryLots.Name   = "nudEntryLots";
            nudEntryLots.BeginInit();
            nudEntryLots.Minimum       = 0.01M;
            nudEntryLots.Maximum       = 100;
            nudEntryLots.Increment     = 0.01M;
            nudEntryLots.Value         = 1;
            nudEntryLots.DecimalPlaces = 2;
            nudEntryLots.TextAlign     = HorizontalAlignment.Center;
            nudEntryLots.EndInit();

            // Label Entry Lots %
            lblPercent1.Parent    = pnlAmounts;
            lblPercent1.ForeColor = colorText;
            lblPercent1.BackColor = Color.Transparent;

            // Label Adding Lots
            lblAddingLots.Parent    = pnlAmounts;
            lblAddingLots.ForeColor = colorText;
            lblAddingLots.BackColor = Color.Transparent;
            lblAddingLots.AutoSize  = true;
            lblAddingLots.Text      = Language.T("In case of addition - number of lots to add");

            // NumericUpDown Adding Lots
            nudAddingLots.Parent = pnlAmounts;
            nudAddingLots.Name   = "nudAddingLots";
            nudAddingLots.BeginInit();
            nudAddingLots.Minimum       = 0.01M;
            nudAddingLots.Maximum       = 100;
            nudAddingLots.Increment     = 0.01M;
            nudAddingLots.Value         = 1;
            nudAddingLots.DecimalPlaces = 2;
            nudAddingLots.TextAlign     = HorizontalAlignment.Center;
            nudAddingLots.EndInit();

            // Label Adding Lots %
            lblPercent2.Parent    = pnlAmounts;
            lblPercent2.ForeColor = colorText;
            lblPercent2.BackColor = Color.Transparent;

            // Label Reducing Lots
            lblReducingLots.Parent    = pnlAmounts;
            lblReducingLots.ForeColor = colorText;
            lblReducingLots.BackColor = Color.Transparent;
            lblReducingLots.AutoSize  = true;
            lblReducingLots.Text      = Language.T("In case of reduction - number of lots to close");

            // NumericUpDown Reducing Lots
            nudReducingLots.Parent = pnlAmounts;
            nudReducingLots.Name   = "nudReducingLots";
            nudReducingLots.BeginInit();
            nudReducingLots.Minimum       = 0.01M;
            nudReducingLots.Maximum       = 100;
            nudReducingLots.Increment     = 0.01m;
            nudReducingLots.DecimalPlaces = 2;
            nudReducingLots.Value         = 1;
            nudReducingLots.TextAlign     = HorizontalAlignment.Center;
            nudReducingLots.EndInit();

            // Label Reducing Lots %
            lblPercent3.Parent    = pnlAmounts;
            lblPercent3.ForeColor = colorText;
            lblPercent3.BackColor = Color.Transparent;

            // CheckBox Permanent Stop Loss
            chbPermaSL.Name      = "chbPermaSL";
            chbPermaSL.Parent    = pnlProtection;
            chbPermaSL.ForeColor = colorText;
            chbPermaSL.BackColor = Color.Transparent;
            chbPermaSL.AutoCheck = true;
            chbPermaSL.AutoSize  = true;
            chbPermaSL.Checked   = false;
            chbPermaSL.Text      = Language.T("Permanent Stop Loss");

            // ComboBox cbxPermaSLType
            cbxPermaSLType.Parent        = pnlProtection;
            cbxPermaSLType.Name          = "cbxPermaSLType";
            cbxPermaSLType.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPermaSLType.Items.AddRange(new string[] { Language.T("Relative"), Language.T("Absolute") });
            cbxPermaSLType.SelectedIndex = 0;

            // NumericUpDown Permanent S/L
            nudPermaSL.Name   = "nudPermaSL";
            nudPermaSL.Parent = pnlProtection;
            nudPermaSL.BeginInit();
            nudPermaSL.Minimum   = 5;
            nudPermaSL.Maximum   = 5000;
            nudPermaSL.Increment = 1;
            nudPermaSL.Value     = (Data.InstrProperties.Digits == 5 || Data.InstrProperties.Digits == 3) ? 1000 : 100;
            nudPermaSL.TextAlign = HorizontalAlignment.Center;
            nudPermaSL.EndInit();

            // CheckBox Permanent Take Profit
            chbPermaTP.Name      = "chbPermaTP";
            chbPermaTP.Parent    = pnlProtection;
            chbPermaTP.ForeColor = colorText;
            chbPermaTP.BackColor = Color.Transparent;
            chbPermaTP.AutoCheck = true;
            chbPermaTP.AutoSize  = true;
            chbPermaTP.Checked   = false;
            chbPermaTP.Text      = Language.T("Permanent Take Profit");

            // ComboBox cbxPermaTPType
            cbxPermaTPType.Parent        = pnlProtection;
            cbxPermaTPType.Name          = "cbxPermaTPType";
            cbxPermaTPType.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPermaTPType.Items.AddRange(new string[] { Language.T("Relative"), Language.T("Absolute") });
            cbxPermaTPType.SelectedIndex = 0;

            // NumericUpDown Permanent Take Profit
            nudPermaTP.Parent = pnlProtection;
            nudPermaTP.Name   = "nudPermaTP";
            nudPermaTP.BeginInit();
            nudPermaTP.Minimum   = 5;
            nudPermaTP.Maximum   = 5000;
            nudPermaTP.Increment = 1;
            nudPermaTP.Value     = (Data.InstrProperties.Digits == 5 || Data.InstrProperties.Digits == 3) ? 1000 : 100;
            nudPermaTP.TextAlign = HorizontalAlignment.Center;
            nudPermaTP.EndInit();

            //Button Default
            btnDefault.Parent = this;
            btnDefault.Name   = "btnDefault";
            btnDefault.Text   = Language.T("Default");
            btnDefault.Click += new EventHandler(BtnDefault_Click);
            btnDefault.UseVisualStyleBackColor = true;

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

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

            return;
        }
        protected Small_Balance_Chart smallBalanceChart;       // Small Balance Chart

        /// <summary>
        /// Initializes the controls in panel pnlOverview
        /// </summary>
        void InitializeAccount()
        {
            string[] asMethods = Enum.GetNames(typeof(InterpolationMethod));
            for (int i = 0; i < asMethods.Length; i++)
            {
                asMethods[i] = Language.T(asMethods[i]);
            }

            Graphics g = CreateGraphics();
            int      iLongestMethod = 0;

            foreach (string sMethod in asMethods)
            {
                if ((int)g.MeasureString(sMethod, Font).Width > iLongestMethod)
                {
                    iLongestMethod = (int)g.MeasureString(sMethod, Font).Width;
                }
            }
            g.Dispose();

            // ComboBox Interpolation Methods
            tscbInterpolationMethod               = new ToolStripComboBox();
            tscbInterpolationMethod.Name          = "tscbInterpolationMethod";
            tscbInterpolationMethod.AutoSize      = false;
            tscbInterpolationMethod.DropDownStyle = ComboBoxStyle.DropDownList;
            tscbInterpolationMethod.Items.AddRange(asMethods);
            tscbInterpolationMethod.SelectedIndex         = 0;
            tscbInterpolationMethod.Width                 = iLongestMethod + (int)(18 * Data.HorizontalDLU);
            tscbInterpolationMethod.ToolTipText           = Language.T("Bar interpolation method.");
            tscbInterpolationMethod.SelectedIndexChanged += new EventHandler(SelectedIndexChanged);
            tsAccount.Items.Add(tscbInterpolationMethod);

            // Button Comparator
            tsbtComparator             = new ToolStripButton();
            tsbtComparator.Text        = Language.T("Comparator");
            tsbtComparator.Name        = "Comparator";
            tsbtComparator.Click      += new EventHandler(BtnTools_OnClick);
            tsbtComparator.ToolTipText = Language.T("Compare the interpolating methods.");
            tsAccount.Items.Add(tsbtComparator);

            // Button Scanner
            tsbtScanner             = new ToolStripButton();
            tsbtScanner.Text        = Language.T("Scanner");
            tsbtScanner.Name        = "Scanner";
            tsbtScanner.Click      += new EventHandler(BtnTools_OnClick);
            tsbtScanner.ToolTipText = Language.T("Perform a deep intrabar scan.") + Environment.NewLine + Language.T("Quick scan") + " - F6.";
            tsAccount.Items.Add(tsbtScanner);

            // Button Analyzer
            tsbtAnalyzer        = new ToolStripButton();
            tsbtAnalyzer.Text   = Language.T("Analyzer");
            tsbtAnalyzer.Name   = "Analyzer";
            tsbtAnalyzer.Click += new EventHandler(BtnTools_OnClick);
            tsAccount.Items.Add(tsbtAnalyzer);

            // Info Panel Account Statistics
            infpnlAccountStatistics        = new Info_Panel();
            infpnlAccountStatistics.Parent = pnlAccount;
            infpnlAccountStatistics.Dock   = DockStyle.Fill;

            Splitter spliter = new Splitter();

            spliter.Parent      = pnlAccount;
            spliter.Dock        = DockStyle.Bottom;
            spliter.BorderStyle = BorderStyle.None;
            spliter.Height      = space;

            // Small Balance Chart
            smallBalanceChart                 = new Small_Balance_Chart();
            smallBalanceChart.Parent          = pnlAccount;
            smallBalanceChart.Cursor          = Cursors.Hand;
            smallBalanceChart.Dock            = DockStyle.Bottom;
            smallBalanceChart.MinimumSize     = new Size(100, 50);
            smallBalanceChart.ShowDynamicInfo = true;
            smallBalanceChart.MouseMove      += new MouseEventHandler(SmallBalanceChart_MouseMove);
            smallBalanceChart.MouseLeave     += new EventHandler(SmallBalanceChart_MouseLeave);
            smallBalanceChart.MouseUp        += new MouseEventHandler(SmallBalanceChart_MouseUp);
            toolTip.SetToolTip(smallBalanceChart, Language.T("Click to view the full chart.") +
                               Environment.NewLine +
                               Language.T("Right click to detach chart."));

            pnlAccount.Resize += new EventHandler(pnlAccount_Resize);

            return;
        }
        public Strategy_Properties()
        {
            pnlAveraging  = new Fancy_Panel(Language.T("Handling of Additional Entry Signals"), LayoutColors.ColorSlotCaptionBackAveraging);
            pnlAmounts    = new Fancy_Panel(Language.T("Trading Size"), LayoutColors.ColorSlotCaptionBackAveraging);
            pnlProtection = new Fancy_Panel(Language.T("Permanent Protection"), LayoutColors.ColorSlotCaptionBackAveraging);
            pnlSmallBalanceChart = new Small_Balance_Chart();

            lblPercent1  = new Label();
            lblPercent2  = new Label();
            lblPercent3  = new Label();

            lblSameDirAction = new Label();
            lblOppDirAction  = new Label();

            cbxSameDirAction = new ComboBox();
            cbxOppDirAction  = new ComboBox();
            nudMaxOpenLots   = new NUD();
            rbConstantUnits  = new RadioButton();
            rbVariableUnits  = new RadioButton();
            nudEntryLots     = new NUD();
            nudAddingLots    = new NUD();
            nudReducingLots  = new NUD();
            lblMaxOpenLots   = new Label();
            lblEntryLots     = new Label();
            lblAddingLots    = new Label();
            lblReducingLots  = new Label();

            chbPermaSL = new CheckBox();
            cbxPermaSLType = new ComboBox();
            nudPermaSL = new NUD();
            chbPermaTP = new CheckBox();
            cbxPermaTPType = new ComboBox();
            nudPermaTP = new NUD();
            chbBreakEven = new CheckBox();
            nudBreakEven = new NUD();

            btnAccept  = new Button();
            btnDefault = new Button();
            btnCancel  = new Button();

            font      = this.Font;
            colorText = LayoutColors.ColorControlText;

            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            Icon            = Data.Icon;
            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            AcceptButton    = btnAccept;
            Text            = Language.T("Strategy Properties");

            pnlAveraging.Parent  = this;
            pnlAmounts.Parent    = this;
            pnlProtection.Parent = this;
            pnlSmallBalanceChart.Parent = this;
            pnlSmallBalanceChart.SetChartData();

            // Label Same dir action
            lblSameDirAction.Parent    = pnlAveraging;
            lblSameDirAction.ForeColor = colorText;
            lblSameDirAction.BackColor = Color.Transparent;
            lblSameDirAction.AutoSize  = true;
            lblSameDirAction.Text      = Language.T("Next same direction signal behavior");

            // Label Opposite dir action
            lblOppDirAction.Parent    = pnlAveraging;
            lblOppDirAction.ForeColor = colorText;
            lblOppDirAction.BackColor = Color.Transparent;
            lblOppDirAction.AutoSize  = true;
            lblOppDirAction.Text      = Language.T("Next opposite direction signal behavior");

            // ComboBox SameDirAction
            cbxSameDirAction.Parent        = pnlAveraging;
            cbxSameDirAction.Name          = "cbxSameDirAction";
            cbxSameDirAction.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxSameDirAction.Items.AddRange(new string[] { Language.T("Nothing"), Language.T("Winner"), Language.T("Add") });
            cbxSameDirAction.SelectedIndex = 0;
            toolTip.SetToolTip(cbxSameDirAction,
                Language.T("Nothing - cancels the additional orders.") + Environment.NewLine +
                Language.T("Winner - adds to a winning position.")     + Environment.NewLine +
                Language.T("Add - adds to all positions."));

            // ComboBox OppDirAction
            cbxOppDirAction.Parent        = pnlAveraging;
            cbxOppDirAction.Name          = "cbxOppDirAction";
            cbxOppDirAction.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxOppDirAction.Items.AddRange(new string[] { Language.T("Nothing"), Language.T("Reduce"), Language.T("Close"), Language.T("Reverse") });
            cbxOppDirAction.SelectedIndex = 0;
            toolTip.SetToolTip(cbxOppDirAction,
                Language.T("Nothing - cancels the additional orders.") + Environment.NewLine +
                Language.T("Reduce - reduces or closes a position.")   + Environment.NewLine +
                Language.T("Close - closes the position.")             + Environment.NewLine +
                Language.T("Reverse - reverses the position."));

            // Label MaxOpen Lots
            lblMaxOpenLots.Parent    = pnlAmounts;
            lblMaxOpenLots.ForeColor = colorText;
            lblMaxOpenLots.BackColor = Color.Transparent;
            lblMaxOpenLots.AutoSize  = true;
            lblMaxOpenLots.Text      = Language.T("Maximum number of open lots");

            // NumericUpDown MaxOpen Lots
            nudMaxOpenLots.Parent    = pnlAmounts;
            nudMaxOpenLots.Name      = "nudMaxOpenLots";
            nudMaxOpenLots.BeginInit();
            nudMaxOpenLots.Minimum   = 0.01M;
            nudMaxOpenLots.Maximum   = 100;
            nudMaxOpenLots.Increment = 0.01M;
            nudMaxOpenLots.Value     = 20;
            nudMaxOpenLots.DecimalPlaces = 2;
            nudMaxOpenLots.TextAlign = HorizontalAlignment.Center;
            nudMaxOpenLots.EndInit();

            // Radio Button Constant Units
            rbConstantUnits.Parent    = pnlAmounts;
            rbConstantUnits.ForeColor = colorText;
            rbConstantUnits.BackColor = Color.Transparent;
            rbConstantUnits.Checked   = true;
            rbConstantUnits.AutoSize  = true;
            rbConstantUnits.Name      = "rbConstantUnits";
            rbConstantUnits.Text      = Language.T("Trade a constant number of lots");

            // Radio Button Variable Units
            rbVariableUnits.Parent    = pnlAmounts;
            rbVariableUnits.ForeColor = colorText;
            rbVariableUnits.BackColor = Color.Transparent;
            rbVariableUnits.Checked   = false;
            rbVariableUnits.AutoSize  = false;
            rbVariableUnits.Name      = "rbVariableUnits";
            rbVariableUnits.Text      = Language.T("Trade percent of your account. The percentage values show the part of the account equity used to cover the required margin.");

            // Label Entry Lots
            lblEntryLots.Parent    = pnlAmounts;
            lblEntryLots.ForeColor = colorText;
            lblEntryLots.BackColor = Color.Transparent;
            lblEntryLots.AutoSize  = true;
            lblEntryLots.Text      = Language.T("Number of entry lots for a new position");

            // NumericUpDown Entry Lots
            nudEntryLots.Parent    = pnlAmounts;
            nudEntryLots.Name      = "nudEntryLots";
            nudEntryLots.BeginInit();
            nudEntryLots.Minimum   = 0.01M;
            nudEntryLots.Maximum   = 100;
            nudEntryLots.Increment = 0.01M;
            nudEntryLots.Value     = 1;
            nudEntryLots.DecimalPlaces = 2;
            nudEntryLots.TextAlign = HorizontalAlignment.Center;
            nudEntryLots.EndInit();

            // Label Entry Lots %
            lblPercent1.Parent    = pnlAmounts;
            lblPercent1.ForeColor = colorText;
            lblPercent1.BackColor = Color.Transparent;

            // Label Adding Lots
            lblAddingLots.Parent    = pnlAmounts;
            lblAddingLots.ForeColor = colorText;
            lblAddingLots.BackColor = Color.Transparent;
            lblAddingLots.AutoSize  = true;
            lblAddingLots.Text      = Language.T("In case of addition - number of lots to add");

            // NumericUpDown Adding Lots
            nudAddingLots.Parent    = pnlAmounts;
            nudAddingLots.Name      = "nudAddingLots";
            nudAddingLots.BeginInit();
            nudAddingLots.Minimum   = 0.01M;
            nudAddingLots.Maximum   = 100;
            nudAddingLots.Increment = 0.01M;
            nudAddingLots.Value     = 1;
            nudAddingLots.DecimalPlaces = 2;
            nudAddingLots.TextAlign = HorizontalAlignment.Center;
            nudAddingLots.EndInit();

            // Label Adding Lots %
            lblPercent2.Parent    = pnlAmounts;
            lblPercent2.ForeColor = colorText;
            lblPercent2.BackColor = Color.Transparent;

            // Label Reducing Lots
            lblReducingLots.Parent    = pnlAmounts;
            lblReducingLots.ForeColor = colorText;
            lblReducingLots.BackColor = Color.Transparent;
            lblReducingLots.AutoSize  = true;
            lblReducingLots.Text      = Language.T("In case of reduction - number of lots to close");

            // NumericUpDown Reducing Lots
            nudReducingLots.Parent    = pnlAmounts;
            nudReducingLots.Name      = "nudReducingLots";
            nudReducingLots.BeginInit();
            nudReducingLots.Minimum   = 0.01M;
            nudReducingLots.Maximum   = 100;
            nudReducingLots.Increment = 0.01m;
            nudReducingLots.DecimalPlaces = 2;
            nudReducingLots.Value     = 1;
            nudReducingLots.TextAlign = HorizontalAlignment.Center;
            nudReducingLots.EndInit();

            // Label Reducing Lots %
            lblPercent3.Parent    = pnlAmounts;
            lblPercent3.ForeColor = colorText;
            lblPercent3.BackColor = Color.Transparent;

            // CheckBox Permanent Stop Loss
            chbPermaSL.Name      = "chbPermaSL";
            chbPermaSL.Parent    = pnlProtection;
            chbPermaSL.ForeColor = colorText;
            chbPermaSL.BackColor = Color.Transparent;
            chbPermaSL.AutoCheck = true;
            chbPermaSL.AutoSize  = true;
            chbPermaSL.Checked   = false;
            chbPermaSL.Text      = Language.T("Permanent Stop Loss");

            // ComboBox cbxPermaSLType
            cbxPermaSLType.Parent  = pnlProtection;
            cbxPermaSLType.Name    = "cbxPermaSLType";
            cbxPermaSLType.Visible = false;
            cbxPermaSLType.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPermaSLType.Items.AddRange(new string[] { Language.T("Relative"), Language.T("Absolute") });
            cbxPermaSLType.SelectedIndex = 0;

            // NumericUpDown Permanent S/L
            nudPermaSL.Name      = "nudPermaSL";
            nudPermaSL.Parent    = pnlProtection;
            nudPermaSL.BeginInit();
            nudPermaSL.Minimum   = 5;
            nudPermaSL.Maximum   = 5000;
            nudPermaSL.Increment = 1;
            nudPermaSL.Value     = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            nudPermaSL.TextAlign = HorizontalAlignment.Center;
            nudPermaSL.EndInit();

            // CheckBox Permanent Take Profit
            chbPermaTP.Name      = "chbPermaTP";
            chbPermaTP.Parent    = pnlProtection;
            chbPermaTP.ForeColor = colorText;
            chbPermaTP.BackColor = Color.Transparent;
            chbPermaTP.AutoCheck = true;
            chbPermaTP.AutoSize  = true;
            chbPermaTP.Checked   = false;
            chbPermaTP.Text      = Language.T("Permanent Take Profit");

            // ComboBox cbxPermaTPType
            cbxPermaTPType.Parent  = pnlProtection;
            cbxPermaTPType.Name    = "cbxPermaTPType";
            cbxPermaTPType.Visible = false;
            cbxPermaTPType.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPermaTPType.Items.AddRange(new string[] { Language.T("Relative"), Language.T("Absolute") });
            cbxPermaTPType.SelectedIndex = 0;

            // NumericUpDown Permanent Take Profit
            nudPermaTP.Parent    = pnlProtection;
            nudPermaTP.Name      = "nudPermaTP";
            nudPermaTP.BeginInit();
            nudPermaTP.Minimum   = 5;
            nudPermaTP.Maximum   = 5000;
            nudPermaTP.Increment = 1;
            nudPermaTP.Value     = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            nudPermaTP.TextAlign = HorizontalAlignment.Center;
            nudPermaTP.EndInit();

            // CheckBox Break Even
            chbBreakEven.Name      = "chbBreakEven";
            chbBreakEven.Parent    = pnlProtection;
            chbBreakEven.ForeColor = colorText;
            chbBreakEven.BackColor = Color.Transparent;
            chbBreakEven.AutoCheck = true;
            chbBreakEven.AutoSize  = true;
            chbBreakEven.Checked   = false;
            chbBreakEven.Text      = Language.T("Break Even");

            // NumericUpDown Break Even
            nudBreakEven.Parent    = pnlProtection;
            nudBreakEven.Name      = "nudBreakEven";
            nudBreakEven.BeginInit();
            nudBreakEven.Minimum   = 5;
            nudBreakEven.Maximum   = 5000;
            nudBreakEven.Increment = 1;
            nudBreakEven.Value     = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            nudBreakEven.TextAlign = HorizontalAlignment.Center;
            nudBreakEven.EndInit();

            //Button Default
            btnDefault.Parent = this;
            btnDefault.Name   = "btnDefault";
            btnDefault.Text   = Language.T("Default");
            btnDefault.Click += new EventHandler(BtnDefault_Click);
            btnDefault.UseVisualStyleBackColor = true;

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

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

            return;
        }
Exemple #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Scanner()
        {
            pnlInfo           = new Panel();
            smallBalanceChart = new Small_Balance_Chart();
            progressBar       = new ProgressBar();
            lblProgress       = new Label();
            chbAutoscan       = new CheckBox();
            chbTickScan       = new CheckBox();
            btnClose          = new Button();

            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            Icon            = Data.Icon;
            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            AcceptButton    = btnClose;
            Text            = Language.T("Intrabar Scanner");
            FormClosing    += new FormClosingEventHandler(Scanner_FormClosing);

            font           = this.Font;
            colorText      = LayoutColors.ColorControlText;
            fontInfo       = new Font(Font.FontFamily, 9);
            infoRowHeight  = (int)Math.Max(fontInfo.Height, 18);
            isTickDataFile = CheckTickDataFile();

            // pnlInfo
            pnlInfo.Parent    = this;
            pnlInfo.BackColor = LayoutColors.ColorControlBack;
            pnlInfo.Paint    += new PaintEventHandler(PnlInfo_Paint);

            // Small Balance Chart
            smallBalanceChart.Parent = this;
            smallBalanceChart.SetChartData();

            // ProgressBar
            progressBar.Parent = this;

            // Label Progress
            lblProgress.Parent    = this;
            lblProgress.ForeColor = LayoutColors.ColorControlText;
            lblProgress.AutoSize  = true;

            // Automatic Scan checkbox.
            chbAutoscan.Parent          = this;
            chbAutoscan.ForeColor       = colorText;
            chbAutoscan.BackColor       = Color.Transparent;
            chbAutoscan.Text            = Language.T("Automatic Scan");
            chbAutoscan.Checked         = Configs.Autoscan;
            chbAutoscan.AutoSize        = true;
            chbAutoscan.CheckedChanged += new EventHandler(ChbAutoscan_CheckedChanged);

            // Tick Scan checkbox.
            chbTickScan.Parent          = this;
            chbTickScan.ForeColor       = colorText;
            chbTickScan.BackColor       = Color.Transparent;
            chbTickScan.Text            = Language.T("Use Ticks");
            chbTickScan.Checked         = Configs.UseTickData && isTickDataFile;
            chbTickScan.AutoSize        = true;
            chbTickScan.Visible         = isTickDataFile;
            chbTickScan.CheckedChanged += new EventHandler(ChbTickScan_CheckedChanged);

            //Button Close
            btnClose.Parent                  = this;
            btnClose.Name                    = "Close";
            btnClose.Text                    = Language.T("Close");
            btnClose.DialogResult            = DialogResult.OK;
            btnClose.UseVisualStyleBackColor = true;

            // BackGroundWorker
            bgWorker = new BackgroundWorker();
            bgWorker.WorkerReportsProgress      = true;
            bgWorker.WorkerSupportsCancellation = true;
            bgWorker.DoWork             += new DoWorkEventHandler(BgWorker_DoWork);
            bgWorker.ProgressChanged    += new ProgressChangedEventHandler(BgWorker_ProgressChanged);
            bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BgWorker_RunWorkerCompleted);

            isLoadingNow = false;

            if (!isTickDataFile)
            {
                Configs.UseTickData = false;
            }

            return;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public Scanner()
        {
            pnlInfo           = new Panel();
            smallBalanceChart = new Small_Balance_Chart();
            progressBar       = new ProgressBar();
            lblProgress       = new Label();
            chbAutoscan       = new CheckBox();
            chbTickScan       = new CheckBox();
            btnClose          = new Button();

            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            Icon            = Data.Icon;
            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            AcceptButton    = btnClose;
            Text            = Language.T("Intrabar Scanner");
            FormClosing    += new FormClosingEventHandler(Scanner_FormClosing);

            font            = this.Font;
            colorText       = LayoutColors.ColorControlText;
            fontInfo        = new Font(Font.FontFamily, 9);
            infoRowHeight   = (int)Math.Max(fontInfo.Height, 18);
            isTickDataFile  = CheckTickDataFile();

            // pnlInfo
            pnlInfo.Parent    = this;
            pnlInfo.BackColor = LayoutColors.ColorControlBack;
            pnlInfo.Paint    += new PaintEventHandler(PnlInfo_Paint);

            // Small Balance Chart
            smallBalanceChart.Parent = this;
            smallBalanceChart.SetChartData();

            // ProgressBar
            progressBar.Parent = this;

            // Label Progress
            lblProgress.Parent    = this;
            lblProgress.ForeColor = LayoutColors.ColorControlText;
            lblProgress.AutoSize = true;

            // Automatic Scan checkbox.
            chbAutoscan.Parent    = this;
            chbAutoscan.ForeColor = colorText;
            chbAutoscan.BackColor = Color.Transparent;
            chbAutoscan.Text      = Language.T("Automatic Scan");
            chbAutoscan.Checked   = Configs.Autoscan;
            chbAutoscan.AutoSize  = true;
            chbAutoscan.CheckedChanged += new EventHandler(ChbAutoscan_CheckedChanged);

            // Tick Scan checkbox.
            chbTickScan.Parent    = this;
            chbTickScan.ForeColor = colorText;
            chbTickScan.BackColor = Color.Transparent;
            chbTickScan.Text      = Language.T("Use Ticks");
            chbTickScan.Checked   = Configs.UseTickData && isTickDataFile;
            chbTickScan.AutoSize  = true;
            chbTickScan.Visible   = isTickDataFile;
            chbTickScan.CheckedChanged += new EventHandler(ChbTickScan_CheckedChanged);

            //Button Close
            btnClose.Parent       = this;
            btnClose.Name         = "Close";
            btnClose.Text         = Language.T("Close");
            btnClose.DialogResult = DialogResult.OK;
            btnClose.UseVisualStyleBackColor = true;

            // BackGroundWorker
            bgWorker = new BackgroundWorker();
            bgWorker.WorkerReportsProgress      = true;
            bgWorker.WorkerSupportsCancellation = true;
            bgWorker.DoWork             += new DoWorkEventHandler(BgWorker_DoWork);
            bgWorker.ProgressChanged    += new ProgressChangedEventHandler(BgWorker_ProgressChanged);
            bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BgWorker_RunWorkerCompleted);

            isLoadingNow = false;

            if (!isTickDataFile)
                Configs.UseTickData = false;

            return;
        }
        /// <summary>
        /// Initializes the controls in panel pnlOverview
        /// </summary>
        void InitializeAccount()
        {
            string[] asMethods = Enum.GetNames(typeof(InterpolationMethod));
            for (int i = 0; i < asMethods.Length; i++)
                asMethods[i] = Language.T(asMethods[i]);

            Graphics g = CreateGraphics();
            int iLongestMethod = 0;
            foreach (string sMethod in asMethods)
                if ((int)g.MeasureString(sMethod, Font).Width > iLongestMethod)
                    iLongestMethod = (int)g.MeasureString(sMethod, Font).Width;
            g.Dispose();

            // ComboBox Interpolation Methods
            tscbInterpolationMethod = new ToolStripComboBox();
            tscbInterpolationMethod.Name          = "tscbInterpolationMethod";
            tscbInterpolationMethod.AutoSize      = false;
            tscbInterpolationMethod.DropDownStyle = ComboBoxStyle.DropDownList;
            tscbInterpolationMethod.Items.AddRange(asMethods);
            tscbInterpolationMethod.SelectedIndex = 0;
            tscbInterpolationMethod.Width         = iLongestMethod + (int)(18 * Data.HorizontalDLU);
            tscbInterpolationMethod.ToolTipText   = Language.T("Bar interpolation method.");
            tscbInterpolationMethod.SelectedIndexChanged += new EventHandler(SelectedIndexChanged);
            tsAccount.Items.Add(tscbInterpolationMethod);

            // Button Comparator
            tsbtComparator =  new ToolStripButton();
            tsbtComparator.Text        = Language.T("Comparator");
            tsbtComparator.Name        = "Comparator";
            tsbtComparator.Click      += new EventHandler(BtnTools_OnClick);
            tsbtComparator.ToolTipText = Language.T("Compare the interpolating methods.");
            tsAccount.Items.Add(tsbtComparator);

            // Button Scanner
            tsbtScanner = new ToolStripButton();
            tsbtScanner.Text        = Language.T("Scanner");
            tsbtScanner.Name        = "Scanner";
            tsbtScanner.Click      += new EventHandler(BtnTools_OnClick);
            tsbtScanner.ToolTipText = Language.T("Perform a deep intrabar scan.") + Environment.NewLine + Language.T("Quick scan") + " - F6.";
            tsAccount.Items.Add(tsbtScanner);

            // Button Analyzer
            tsbtAnalyzer = new ToolStripButton();
            tsbtAnalyzer.Text   = Language.T("Analyzer");
            tsbtAnalyzer.Name   = "Analyzer";
            tsbtAnalyzer.Click += new EventHandler(BtnTools_OnClick);
            tsAccount.Items.Add(tsbtAnalyzer);

            // Info Panel Account Statistics
            infpnlAccountStatistics = new Info_Panel();
            infpnlAccountStatistics.Parent = pnlAccount;
            infpnlAccountStatistics.Dock   = DockStyle.Fill;

            Splitter spliter    = new Splitter();
            spliter.Parent      = pnlAccount;
            spliter.Dock        = DockStyle.Bottom;
            spliter.BorderStyle = BorderStyle.None;
            spliter.Height      = space;

            // Small Balance Chart
            smallBalanceChart = new Small_Balance_Chart();
            smallBalanceChart.Parent          = pnlAccount;
            smallBalanceChart.Cursor          = Cursors.Hand;
            smallBalanceChart.Dock            = DockStyle.Bottom;
            smallBalanceChart.MinimumSize     = new Size(100, 50);
            smallBalanceChart.ShowDynamicInfo = true;
            smallBalanceChart.MouseMove      += new MouseEventHandler(SmallBalanceChart_MouseMove);
            smallBalanceChart.MouseLeave     += new EventHandler(SmallBalanceChart_MouseLeave);
            smallBalanceChart.MouseUp        += new MouseEventHandler(SmallBalanceChart_MouseUp);
            toolTip.SetToolTip(smallBalanceChart, Language.T("Click to view the full chart.") +
                                                  Environment.NewLine +
                                                  Language.T("Right click to detach chart."));

            pnlAccount.Resize += new EventHandler(pnlAccount_Resize);

            return;
        }
        // ---------------------------------------------------------------------------
        /// <summary>
        /// Constructor
        /// </summary>
        public Indicator_Dialog(int slotNumb, SlotTypes slotType, bool isDefined)
        {
            this.slot      = slotNumb;
            this.slotType   = slotType;
            this.isDefined = isDefined;

            if (slotType == SlotTypes.Open)
            {
                slotCation      = Language.T("Opening Point of the Position");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackOpen);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackOpen);
            }
            else if (slotType == SlotTypes.OpenFilter)
            {
                slotCation      = Language.T("Opening Logic Condition");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackOpenFilter);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackOpenFilter);
            }
            else if (slotType == SlotTypes.Close)
            {
                slotCation      = Language.T("Closing Point of the Position");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackClose);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackClose);
            }
            else
            {
                slotCation      = Language.T("Closing Logic Condition");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackCloseFilter);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackCloseFilter);
            }

            trvIndicators        = new TreeView();
            pnlSmallBalanceChart = new Small_Balance_Chart();
            btnAccept            = new Button();
            btnHelp              = new Button();
            btnDefault           = new Button();
            btnCancel            = new Button();

            lblIndicatorInfo     = new Label();
            lblIndicatorWarning  = new Label();
            lblIndicator         = new Label();
            lblGroup             = new Label();
            cbxGroup             = new ComboBox();
            aLblList             = new Label[5];
            aCbxList             = new ComboBox[5];
            aLblNumeric          = new Label[6];
            aNudNumeric          = new NUD[6];
            aChbCheck            = new CheckBox[2];

            BackColor            = LayoutColors.ColorFormBack;
            FormBorderStyle      = FormBorderStyle.FixedDialog;
            Icon                 = Data.Icon;
            MaximizeBox          = false;
            MinimizeBox          = false;
            ShowInTaskbar        = false;
            AcceptButton         = btnAccept;
            CancelButton         = btnCancel;
            Text                 = Language.T("Logic and Parameters of the Indicators");

            // Panel TreeViewBase
            pnlTreeViewBase.Parent  = this;
            pnlTreeViewBase.Padding = new Padding(border, (int)pnlTreeViewBase.CaptionHeight, border, border);

            // TreeView trvIndicators
            trvIndicators.Parent      = pnlTreeViewBase;
            trvIndicators.Dock        = DockStyle.Fill;
            trvIndicators.BackColor   = LayoutColors.ColorControlBack;
            trvIndicators.ForeColor   = LayoutColors.ColorControlText;
            trvIndicators.BorderStyle = BorderStyle.None;
            trvIndicators.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(TrvIndicators_NodeMouseDoubleClick);
            trvIndicators.KeyPress   += new KeyPressEventHandler(TrvIndicators_KeyPress);

            pnlParameters.Parent = this;

            // pnlSmallBalanceChart
            pnlSmallBalanceChart.Parent = this;

            // lblIndicatorInfo
            lblIndicatorInfo.Parent          = pnlParameters;
            lblIndicatorInfo.Size            = new Size(16, 16);
            lblIndicatorInfo.BackColor       = Color.Transparent;
            lblIndicatorInfo.BackgroundImage = Properties.Resources.information;
            lblIndicatorInfo.Click          += new EventHandler(LblIndicatorInfo_Click);
            lblIndicatorInfo.MouseEnter     += new EventHandler(Label_MouseEnter);
            lblIndicatorInfo.MouseLeave     += new EventHandler(Label_MouseLeave);

            // lblIndicatorWarning
            lblIndicatorWarning.Parent          = pnlParameters;
            lblIndicatorWarning.Size            = new Size(16, 16);
            lblIndicatorWarning.BackColor       = Color.Transparent;
            lblIndicatorWarning.BackgroundImage = Properties.Resources.warning;
            lblIndicatorWarning.Visible         = false;
            lblIndicatorWarning.Click          += new EventHandler(LblIndicatorWarning_Click);
            lblIndicatorWarning.MouseEnter     += new EventHandler(Label_MouseEnter);
            lblIndicatorWarning.MouseLeave     += new EventHandler(Label_MouseLeave);

            // Label Indicator
            lblIndicator.Parent    = pnlParameters;
            lblIndicator.TextAlign = ContentAlignment.MiddleCenter;
            lblIndicator.Font      = new Font(Font.FontFamily, 14, FontStyle.Bold);
            lblIndicator.ForeColor = LayoutColors.ColorSlotIndicatorText;
            lblIndicator.BackColor = Color.Transparent;

            // Label aLblList[0]
            aLblList[0]           = new Label();
            aLblList[0].Parent    = pnlParameters;
            aLblList[0].TextAlign = ContentAlignment.BottomCenter;
            aLblList[0].ForeColor = LayoutColors.ColorControlText;
            aLblList[0].BackColor = Color.Transparent;

            // ComboBox aCbxList[0]
            aCbxList[0]               = new ComboBox();
            aCbxList[0].Parent        = pnlParameters;
            aCbxList[0].DropDownStyle = ComboBoxStyle.DropDownList;
            aCbxList[0].SelectedIndexChanged  += new EventHandler(Param_Changed);

            // Logical Group
            lblGroup = new Label();
            lblGroup.Parent    = pnlParameters;
            lblGroup.TextAlign = ContentAlignment.BottomCenter;
            lblGroup.ForeColor = LayoutColors.ColorControlText;
            lblGroup.BackColor = Color.Transparent;
            lblGroup.Text      = Language.T("Group");

            cbxGroup = new ComboBox();
            cbxGroup.Parent  = pnlParameters;
            if(slotType == SlotTypes.OpenFilter)
                cbxGroup.Items.AddRange(new string[] {"A", "B", "C", "D", "E", "F", "G", "H", "All"});
            if(slotType == SlotTypes.CloseFilter)
                cbxGroup.Items.AddRange(new string[] {"a", "b", "c", "d", "e", "f", "g", "h", "all"});
            cbxGroup.SelectedIndexChanged += new EventHandler(Group_Changed);
            cbxGroup.DropDownStyle = ComboBoxStyle.DropDownList;
            toolTip.SetToolTip(cbxGroup, Language.T("The logical group of the slot."));

            // ListParams
            for (int i = 1; i < 5; i++)
            {
                aLblList[i] = new Label();
                aLblList[i].Parent    = pnlParameters;
                aLblList[i].TextAlign = ContentAlignment.BottomCenter;
                aLblList[i].ForeColor = LayoutColors.ColorControlText;
                aLblList[i].BackColor = Color.Transparent;

                aCbxList[i]               = new ComboBox();
                aCbxList[i].Parent        = pnlParameters;
                aCbxList[i].Enabled       = false;
                aCbxList[i].SelectedIndexChanged += new EventHandler(Param_Changed);
                aCbxList[i].DropDownStyle = ComboBoxStyle.DropDownList;
            }

            // NumParams
            for (int i = 0; i < 6; i++)
            {
                aLblNumeric[i] = new Label();
                aLblNumeric[i].Parent    = pnlParameters;
                aLblNumeric[i].TextAlign = ContentAlignment.MiddleRight;
                aLblNumeric[i].ForeColor = LayoutColors.ColorControlText;
                aLblNumeric[i].BackColor = Color.Transparent;

                aNudNumeric[i] = new NUD();
                aNudNumeric[i].Parent        = pnlParameters;
                aNudNumeric[i].TextAlign     = HorizontalAlignment.Center;
                aNudNumeric[i].Enabled       = false;
                aNudNumeric[i].ValueChanged += new EventHandler(Param_Changed);
            }

            // CheckParams
            for (int i = 0; i < 2; i++)
            {
                aChbCheck[i]                 = new CheckBox();
                aChbCheck[i].Parent          = pnlParameters;
                aChbCheck[i].CheckAlign      = ContentAlignment.MiddleLeft;
                aChbCheck[i].TextAlign       = ContentAlignment.MiddleLeft;
                aChbCheck[i].CheckedChanged += new EventHandler(Param_Changed);
                aChbCheck[i].ForeColor       = LayoutColors.ColorControlText;
                aChbCheck[i].BackColor       = Color.Transparent;
                aChbCheck[i].Enabled         = false;
            }

            //Button Accept
            btnAccept.Parent       = this;
            btnAccept.Text         = Language.T("Accept");
            btnAccept.DialogResult = DialogResult.OK;
            btnAccept.Click       += new EventHandler(BtnOk_Click);
            btnAccept.UseVisualStyleBackColor = true;

            //Button Default
            btnDefault.Parent      = this;
            btnDefault.Text        = Language.T("Default");
            btnDefault.Click      += new EventHandler(BtnDefault_Click);
            btnDefault.UseVisualStyleBackColor = true;

            //Button Help
            btnHelp.Parent         = this;
            btnHelp.Text           = Language.T("Help");
            btnHelp.Click         += new EventHandler(BtnHelp_Click);
            btnHelp.UseVisualStyleBackColor = true;

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

            SetTreeViewIndicators();

            // ComboBoxindicator index selection.
            if (isDefined)
            {
                TreeNode [] atrn = trvIndicators.Nodes.Find(Data.Strategy.Slot[slot].IndParam.IndicatorName, true);
                trvIndicators.SelectedNode = atrn[0];
                UpdateFromIndicatorParam(Data.Strategy.Slot[slot].IndParam);
                SetLogicalGroup();
                CalculateIndicator(false);
                pnlSmallBalanceChart.SetChartData();
                pnlSmallBalanceChart.InitChart();
                pnlSmallBalanceChart.Invalidate();
            }
            else
            {
                string defaultIndicator;
                if (slotType == SlotTypes.Open)
                    defaultIndicator = "Bar Opening";
                else if (slotType == SlotTypes.OpenFilter)
                    defaultIndicator = "Accelerator Oscillator";
                else if (slotType == SlotTypes.Close)
                    defaultIndicator = "Bar Closing";
                else
                    defaultIndicator = "Accelerator Oscillator";

                TreeNode[] atrn = trvIndicators.Nodes.Find(defaultIndicator, true);
                trvIndicators.SelectedNode = atrn[0];
                TrvIndicatorsLoadIndicator(atrn[0]);
            }

            oppSignalBehaviour = Data.Strategy.OppSignalAction;

            if (slotType == SlotTypes.Close && Data.Strategy.CloseFilters > 0)
                for (int iSlot = Data.Strategy.CloseSlot + 1; iSlot < Data.Strategy.Slots; iSlot++)
                    closingConditions.Add(Data.Strategy.Slot[iSlot].Clone());

            return;
        }
// ---------------------------------------------------------------------------

        /// <summary>
        /// Constructor
        /// </summary>
        public Indicator_Dialog(int slotNumb, SlotTypes slotType, bool isDefined)
        {
            this.slot      = slotNumb;
            this.slotType  = slotType;
            this.isDefined = isDefined;

            if (slotType == SlotTypes.Open)
            {
                slotCation      = Language.T("Opening Point of the Position");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackOpen);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackOpen);
            }
            else if (slotType == SlotTypes.OpenFilter)
            {
                slotCation      = Language.T("Opening Logic Condition");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackOpenFilter);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackOpenFilter);
            }
            else if (slotType == SlotTypes.Close)
            {
                slotCation      = Language.T("Closing Point of the Position");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackClose);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackClose);
            }
            else
            {
                slotCation      = Language.T("Closing Logic Condition");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackCloseFilter);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackCloseFilter);
            }

            trvIndicators        = new TreeView();
            pnlSmallBalanceChart = new Small_Balance_Chart();
            btnAccept            = new Button();
            btnHelp    = new Button();
            btnDefault = new Button();
            btnCancel  = new Button();

            lblIndicatorInfo    = new Label();
            lblIndicatorWarning = new Label();
            lblIndicator        = new Label();
            lblGroup            = new Label();
            cbxGroup            = new ComboBox();
            aLblList            = new Label[5];
            aCbxList            = new ComboBox[5];
            aLblNumeric         = new Label[6];
            aNudNumeric         = new NUD[6];
            aChbCheck           = new CheckBox[2];

            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            Icon            = Data.Icon;
            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            AcceptButton    = btnAccept;
            CancelButton    = btnCancel;
            Text            = Language.T("Logic and Parameters of the Indicators");

            // Panel TreeViewBase
            pnlTreeViewBase.Parent  = this;
            pnlTreeViewBase.Padding = new Padding(border, (int)pnlTreeViewBase.CaptionHeight, border, border);

            // TreeView trvIndicators
            trvIndicators.Parent                = pnlTreeViewBase;
            trvIndicators.Dock                  = DockStyle.Fill;
            trvIndicators.BackColor             = LayoutColors.ColorControlBack;
            trvIndicators.ForeColor             = LayoutColors.ColorControlText;
            trvIndicators.BorderStyle           = BorderStyle.None;
            trvIndicators.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(TrvIndicators_NodeMouseDoubleClick);
            trvIndicators.KeyPress             += new KeyPressEventHandler(TrvIndicators_KeyPress);

            pnlParameters.Parent = this;

            // pnlSmallBalanceChart
            pnlSmallBalanceChart.Parent = this;

            // lblIndicatorInfo
            lblIndicatorInfo.Parent          = pnlParameters;
            lblIndicatorInfo.Size            = new Size(16, 16);
            lblIndicatorInfo.BackColor       = Color.Transparent;
            lblIndicatorInfo.BackgroundImage = Properties.Resources.information;
            lblIndicatorInfo.Click          += new EventHandler(LblIndicatorInfo_Click);
            lblIndicatorInfo.MouseEnter     += new EventHandler(Label_MouseEnter);
            lblIndicatorInfo.MouseLeave     += new EventHandler(Label_MouseLeave);

            // lblIndicatorWarning
            lblIndicatorWarning.Parent          = pnlParameters;
            lblIndicatorWarning.Size            = new Size(16, 16);
            lblIndicatorWarning.BackColor       = Color.Transparent;
            lblIndicatorWarning.BackgroundImage = Properties.Resources.warning;
            lblIndicatorWarning.Visible         = false;
            lblIndicatorWarning.Click          += new EventHandler(LblIndicatorWarning_Click);
            lblIndicatorWarning.MouseEnter     += new EventHandler(Label_MouseEnter);
            lblIndicatorWarning.MouseLeave     += new EventHandler(Label_MouseLeave);

            // Label Indicator
            lblIndicator.Parent    = pnlParameters;
            lblIndicator.TextAlign = ContentAlignment.MiddleCenter;
            lblIndicator.Font      = new Font(Font.FontFamily, 14, FontStyle.Bold);
            lblIndicator.ForeColor = LayoutColors.ColorSlotIndicatorText;
            lblIndicator.BackColor = Color.Transparent;

            // Label aLblList[0]
            aLblList[0]           = new Label();
            aLblList[0].Parent    = pnlParameters;
            aLblList[0].TextAlign = ContentAlignment.BottomCenter;
            aLblList[0].ForeColor = LayoutColors.ColorControlText;
            aLblList[0].BackColor = Color.Transparent;

            // ComboBox aCbxList[0]
            aCbxList[0]                       = new ComboBox();
            aCbxList[0].Parent                = pnlParameters;
            aCbxList[0].DropDownStyle         = ComboBoxStyle.DropDownList;
            aCbxList[0].SelectedIndexChanged += new EventHandler(Param_Changed);

            // Logical Group
            lblGroup           = new Label();
            lblGroup.Parent    = pnlParameters;
            lblGroup.TextAlign = ContentAlignment.BottomCenter;
            lblGroup.ForeColor = LayoutColors.ColorControlText;
            lblGroup.BackColor = Color.Transparent;
            lblGroup.Text      = Language.T("Group");

            cbxGroup        = new ComboBox();
            cbxGroup.Parent = pnlParameters;
            if (slotType == SlotTypes.OpenFilter)
            {
                cbxGroup.Items.AddRange(new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "All" });
            }
            if (slotType == SlotTypes.CloseFilter)
            {
                cbxGroup.Items.AddRange(new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "all" });
            }
            cbxGroup.SelectedIndexChanged += new EventHandler(Group_Changed);
            cbxGroup.DropDownStyle         = ComboBoxStyle.DropDownList;
            toolTip.SetToolTip(cbxGroup, Language.T("The logical group of the slot."));

            // ListParams
            for (int i = 1; i < 5; i++)
            {
                aLblList[i]           = new Label();
                aLblList[i].Parent    = pnlParameters;
                aLblList[i].TextAlign = ContentAlignment.BottomCenter;
                aLblList[i].ForeColor = LayoutColors.ColorControlText;
                aLblList[i].BackColor = Color.Transparent;

                aCbxList[i]         = new ComboBox();
                aCbxList[i].Parent  = pnlParameters;
                aCbxList[i].Enabled = false;
                aCbxList[i].SelectedIndexChanged += new EventHandler(Param_Changed);
                aCbxList[i].DropDownStyle         = ComboBoxStyle.DropDownList;
            }

            // NumParams
            for (int i = 0; i < 6; i++)
            {
                aLblNumeric[i]           = new Label();
                aLblNumeric[i].Parent    = pnlParameters;
                aLblNumeric[i].TextAlign = ContentAlignment.MiddleRight;
                aLblNumeric[i].ForeColor = LayoutColors.ColorControlText;
                aLblNumeric[i].BackColor = Color.Transparent;

                aNudNumeric[i]               = new NUD();
                aNudNumeric[i].Parent        = pnlParameters;
                aNudNumeric[i].TextAlign     = HorizontalAlignment.Center;
                aNudNumeric[i].Enabled       = false;
                aNudNumeric[i].ValueChanged += new EventHandler(Param_Changed);
            }

            // CheckParams
            for (int i = 0; i < 2; i++)
            {
                aChbCheck[i]                 = new CheckBox();
                aChbCheck[i].Parent          = pnlParameters;
                aChbCheck[i].CheckAlign      = ContentAlignment.MiddleLeft;
                aChbCheck[i].TextAlign       = ContentAlignment.MiddleLeft;
                aChbCheck[i].CheckedChanged += new EventHandler(Param_Changed);
                aChbCheck[i].ForeColor       = LayoutColors.ColorControlText;
                aChbCheck[i].BackColor       = Color.Transparent;
                aChbCheck[i].Enabled         = false;
            }

            //Button Accept
            btnAccept.Parent                  = this;
            btnAccept.Text                    = Language.T("Accept");
            btnAccept.DialogResult            = DialogResult.OK;
            btnAccept.Click                  += new EventHandler(BtnOk_Click);
            btnAccept.UseVisualStyleBackColor = true;

            //Button Default
            btnDefault.Parent = this;
            btnDefault.Text   = Language.T("Default");
            btnDefault.Click += new EventHandler(BtnDefault_Click);
            btnDefault.UseVisualStyleBackColor = true;

            //Button Help
            btnHelp.Parent = this;
            btnHelp.Text   = Language.T("Help");
            btnHelp.Click += new EventHandler(BtnHelp_Click);
            btnHelp.UseVisualStyleBackColor = true;

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

            SetTreeViewIndicators();

            // ComboBoxindicator index selection.
            if (isDefined)
            {
                TreeNode [] atrn = trvIndicators.Nodes.Find(Data.Strategy.Slot[slot].IndParam.IndicatorName, true);
                trvIndicators.SelectedNode = atrn[0];
                UpdateFromIndicatorParam(Data.Strategy.Slot[slot].IndParam);
                SetLogicalGroup();
                CalculateIndicator(false);
                pnlSmallBalanceChart.SetChartData();
                pnlSmallBalanceChart.InitChart();
                pnlSmallBalanceChart.Invalidate();
            }
            else
            {
                string defaultIndicator;
                if (slotType == SlotTypes.Open)
                {
                    defaultIndicator = "Bar Opening";
                }
                else if (slotType == SlotTypes.OpenFilter)
                {
                    defaultIndicator = "Accelerator Oscillator";
                }
                else if (slotType == SlotTypes.Close)
                {
                    defaultIndicator = "Bar Closing";
                }
                else
                {
                    defaultIndicator = "Accelerator Oscillator";
                }

                TreeNode[] atrn = trvIndicators.Nodes.Find(defaultIndicator, true);
                trvIndicators.SelectedNode = atrn[0];
                TrvIndicatorsLoadIndicator(atrn[0]);
            }

            oppSignalBehaviour = Data.Strategy.OppSignalAction;

            if (slotType == SlotTypes.Close && Data.Strategy.CloseFilters > 0)
            {
                for (int iSlot = Data.Strategy.CloseSlot + 1; iSlot < Data.Strategy.Slots; iSlot++)
                {
                    closingConditions.Add(Data.Strategy.Slot[iSlot].Clone());
                }
            }

            return;
        }