public StrategyProperties()
        {
            PnlAveraging = new FancyPanel(Language.T("Handling of Additional Entry Signals"),
                                          LayoutColors.ColorSlotCaptionBackAveraging);
            PnlAmounts = new FancyPanel(Language.T("Trading Size"), LayoutColors.ColorSlotCaptionBackAveraging);
            PnlProtection = new FancyPanel(Language.T("Permanent Protection"),
                                           LayoutColors.ColorSlotCaptionBackAveraging);
            BalanceChart = new SmallBalanceChart();

            LblPercent1 = new Label();
            LblPercent2 = new Label();
            LblPercent3 = new Label();

            LblSameDirAction = new Label();
            LblOppDirAction = new Label();

            CbxSameDirAction = new ComboBox();
            CbxOppDirAction = new ComboBox();
            FancyNudMaxOpenLots = new FancyNud();
            RbConstantUnits = new RadioButton();
            RbVariableUnits = new RadioButton();
            FancyNudEntryLots = new FancyNud();
            FancyNudAddingLots = new FancyNud();
            FancyNudReducingLots = new FancyNud();
            LblMaxOpenLots = new Label();
            LblEntryLots = new Label();
            LblAddingLots = new Label();
            LblReducingLots = new Label();
            CbxUseMartingale = new CheckBox();
            FancyNudMartingaleMultiplier = new FancyNud();

            ChbPermaSL = new CheckBox();
            CbxPermaSLType = new ComboBox();
            FancyNudPermaSL = new FancyNud();
            ChbPermaTP = new CheckBox();
            CbxPermaTPType = new ComboBox();
            FancyNudPermaTP = new FancyNud();
            ChbBreakEven = new CheckBox();
            FancyNudBreakEven = new FancyNud();

            BtnAccept = new Button();
            BtnDefault = new Button();
            BtnCancel = new Button();

            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;
            BalanceChart.Parent = this;
            BalanceChart.SetChartData();

            var toolTip = new ToolTip();

            // 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;
            var sameItems = new[] {Language.T("Nothing"), Language.T("Winner"), Language.T("Add")};
            foreach (string item in sameItems)
                CbxSameDirAction.Items.Add(item);
            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;
            var oppItems = new[]
                {Language.T("Nothing"), Language.T("Reduce"), Language.T("Close"), Language.T("Reverse")};
            foreach (string item in oppItems)
                CbxOppDirAction.Items.Add(item);
            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
            FancyNudMaxOpenLots.Parent = PnlAmounts;
            FancyNudMaxOpenLots.Name = "nudMaxOpenLots";
            FancyNudMaxOpenLots.BeginInit();
            FancyNudMaxOpenLots.Minimum = 0.01M;
            FancyNudMaxOpenLots.Maximum = 100;
            FancyNudMaxOpenLots.Increment = 0.01M;
            FancyNudMaxOpenLots.Value = 20;
            FancyNudMaxOpenLots.DecimalPlaces = 2;
            FancyNudMaxOpenLots.TextAlign = HorizontalAlignment.Center;
            FancyNudMaxOpenLots.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
            FancyNudEntryLots.Parent = PnlAmounts;
            FancyNudEntryLots.Name = "nudEntryLots";
            FancyNudEntryLots.BeginInit();
            FancyNudEntryLots.Minimum = 0.01M;
            FancyNudEntryLots.Maximum = 100;
            FancyNudEntryLots.Increment = 0.01M;
            FancyNudEntryLots.Value = 1;
            FancyNudEntryLots.DecimalPlaces = 2;
            FancyNudEntryLots.TextAlign = HorizontalAlignment.Center;
            FancyNudEntryLots.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
            FancyNudAddingLots.Parent = PnlAmounts;
            FancyNudAddingLots.Name = "nudAddingLots";
            FancyNudAddingLots.BeginInit();
            FancyNudAddingLots.Minimum = 0.01M;
            FancyNudAddingLots.Maximum = 100;
            FancyNudAddingLots.Increment = 0.01M;
            FancyNudAddingLots.Value = 1;
            FancyNudAddingLots.DecimalPlaces = 2;
            FancyNudAddingLots.TextAlign = HorizontalAlignment.Center;
            FancyNudAddingLots.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
            FancyNudReducingLots.Parent = PnlAmounts;
            FancyNudReducingLots.Name = "nudReducingLots";
            FancyNudReducingLots.BeginInit();
            FancyNudReducingLots.Minimum = 0.01M;
            FancyNudReducingLots.Maximum = 100;
            FancyNudReducingLots.Increment = 0.01m;
            FancyNudReducingLots.DecimalPlaces = 2;
            FancyNudReducingLots.Value = 1;
            FancyNudReducingLots.TextAlign = HorizontalAlignment.Center;
            FancyNudReducingLots.EndInit();

            // CheckBox Use Martingale
            CbxUseMartingale.Name = "cbxUseMartingale";
            CbxUseMartingale.Parent = PnlAmounts;
            CbxUseMartingale.ForeColor = ColorText;
            CbxUseMartingale.BackColor = Color.Transparent;
            CbxUseMartingale.AutoCheck = true;
            CbxUseMartingale.AutoSize = true;
            CbxUseMartingale.Checked = false;
            CbxUseMartingale.Text = Language.T("Martingale money management multiplier");

            // NumericUpDown Martingale Multiplier
            FancyNudMartingaleMultiplier.Parent = PnlAmounts;
            FancyNudMartingaleMultiplier.Name = "nudMartingaleMultiplier";
            FancyNudMartingaleMultiplier.BeginInit();
            FancyNudMartingaleMultiplier.Minimum = 0.01M;
            FancyNudMartingaleMultiplier.Maximum = 10;
            FancyNudMartingaleMultiplier.Increment = 0.01m;
            FancyNudMartingaleMultiplier.DecimalPlaces = 2;
            FancyNudMartingaleMultiplier.Value = 2;
            FancyNudMartingaleMultiplier.TextAlign = HorizontalAlignment.Center;
            FancyNudMartingaleMultiplier.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.Add(Language.T("Relative"));
            CbxPermaSLType.Items.Add(Language.T("Absolute"));
            CbxPermaSLType.SelectedIndex = 0;

            // NumericUpDown Permanent S/L
            FancyNudPermaSL.Name = "nudPermaSL";
            FancyNudPermaSL.Parent = PnlProtection;
            FancyNudPermaSL.BeginInit();
            FancyNudPermaSL.Minimum = 5;
            FancyNudPermaSL.Maximum = 5000;
            FancyNudPermaSL.Increment = 1;
            FancyNudPermaSL.Value = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            FancyNudPermaSL.TextAlign = HorizontalAlignment.Center;
            FancyNudPermaSL.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.Add(Language.T("Relative"));
            CbxPermaTPType.Items.Add(Language.T("Absolute"));
            CbxPermaTPType.SelectedIndex = 0;

            // NumericUpDown Permanent Take Profit
            FancyNudPermaTP.Parent = PnlProtection;
            FancyNudPermaTP.Name = "nudPermaTP";
            FancyNudPermaTP.BeginInit();
            FancyNudPermaTP.Minimum = 5;
            FancyNudPermaTP.Maximum = 5000;
            FancyNudPermaTP.Increment = 1;
            FancyNudPermaTP.Value = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            FancyNudPermaTP.TextAlign = HorizontalAlignment.Center;
            FancyNudPermaTP.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
            FancyNudBreakEven.Parent = PnlProtection;
            FancyNudBreakEven.Name = "nudBreakEven";
            FancyNudBreakEven.BeginInit();
            FancyNudBreakEven.Minimum = 5;
            FancyNudBreakEven.Maximum = 5000;
            FancyNudBreakEven.Increment = 1;
            FancyNudBreakEven.Value = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            FancyNudBreakEven.TextAlign = HorizontalAlignment.Center;
            FancyNudBreakEven.EndInit();

            //Button Default
            BtnDefault.Parent = this;
            BtnDefault.Name = "btnDefault";
            BtnDefault.Text = Language.T("Default");
            BtnDefault.Click += BtnDefaultClick;
            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;
        }
Example #2
0
        /// <summary>
        ///     Constructor
        /// </summary>
        public Scanner()
        {
            InfoPanel    = new Panel();
            BalanceChart = new SmallBalanceChart();
            ProgressBar  = new ProgressBar();
            LblProgress  = new Label();
            ChbAutoscan  = new CheckBox();
            ChbTickScan  = new CheckBox();
            BtnClose     = new Button();

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

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

            // pnlInfo
            InfoPanel.Parent    = this;
            InfoPanel.BackColor = LayoutColors.ColorControlBack;
            InfoPanel.Paint    += PnlInfoPaint;

            // Small Balance Chart
            BalanceChart.Parent = this;

            // 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 += ChbAutoscanCheckedChanged;

            // 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 += ChbTickScanCheckedChanged;

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

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

            isLoadingNow = false;

            if (!isTickDataFile)
            {
                Configs.UseTickData = false;
            }
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        public Scanner()
        {
            InfoPanel = new Panel();
            BalanceChart = new SmallBalanceChart();
            ProgressBar = new ProgressBar();
            LblProgress = new Label();
            ChbAutoscan = new CheckBox();
            ChbTickScan = new CheckBox();
            BtnClose = new Button();

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

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

            // pnlInfo
            InfoPanel.Parent = this;
            InfoPanel.BackColor = LayoutColors.ColorControlBack;
            InfoPanel.Paint += PnlInfoPaint;

            // Small Balance Chart
            BalanceChart.Parent = this;

            // 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 += ChbAutoscanCheckedChanged;

            // 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 += ChbTickScanCheckedChanged;

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

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

            isLoadingNow = false;

            if (!isTickDataFile)
                Configs.UseTickData = false;
        }
        /// <summary>
        ///     Initializes the controls in panel pnlOverview
        /// </summary>
        private void InitializeAccount()
        {
            var toolTip = new ToolTip();

            string[] methods = Enum.GetNames(typeof (InterpolationMethod));
            for (int i = 0; i < methods.Length; i++)
                methods[i] = Language.T(methods[i]);

            Graphics g = CreateGraphics();
            int maxWidth = 0;
            foreach (string method in methods)
                if ((int) g.MeasureString(method, Font).Width > maxWidth)
                    maxWidth = (int) g.MeasureString(method, Font).Width;
            g.Dispose();

            // ComboBox Interpolation Methods
            ComboBoxInterpolationMethod = new ToolStripComboBox
                {
                    Name = "ComboBoxInterpolationMethod",
                    AutoSize = false,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                    Width = maxWidth + (int) (18*Data.HorizontalDlu),
                    ToolTipText = Language.T("Bar interpolation method.")
                };
            foreach (string method in methods)
                ComboBoxInterpolationMethod.Items.Add(method);
            ComboBoxInterpolationMethod.SelectedIndex = 0;
            ComboBoxInterpolationMethod.SelectedIndexChanged += SelectedIndexChanged;
            ToolStripAccount.Items.Add(ComboBoxInterpolationMethod);

            // Button Comparator
            var tsbtComparator = new ToolStripButton {Text = Language.T("Comparator"), Name = "Comparator"};
            tsbtComparator.Click += BtnToolsOnClick;
            tsbtComparator.ToolTipText = Language.T("Compare the interpolating methods.");
            ToolStripAccount.Items.Add(tsbtComparator);

            // Button Scanner
            var tsbtScanner = new ToolStripButton {Text = Language.T("Scanner"), Name = "Scanner"};
            tsbtScanner.Click += BtnToolsOnClick;
            tsbtScanner.ToolTipText = Language.T("Perform a deep intrabar scan.") + Environment.NewLine +
                                      Language.T("Quick scan") + " - F6.";
            ToolStripAccount.Items.Add(tsbtScanner);

            // Button Analyzer
            var tsbtAnalyzer = new ToolStripButton {Text = Language.T("Analyzer"), Name = "Analyzer"};
            tsbtAnalyzer.Click += BtnToolsOnClick;
            ToolStripAccount.Items.Add(tsbtAnalyzer);

            // Info Panel Account Statistics
            InfoPanelAccountStatistics = new InfoPanel {Parent = PanelAccount, Dock = DockStyle.Fill};

            new Splitter {Parent = PanelAccount, Dock = DockStyle.Bottom, BorderStyle = BorderStyle.None, Height = Gap};

            // Small Balance Chart
            BalanceChart = new SmallBalanceChart
                {
                    Parent = PanelAccount,
                    Cursor = Cursors.Hand,
                    Dock = DockStyle.Bottom,
                    MinimumSize = new Size(100, 50),
                    ShowDynamicInfo = true,
                    IsContextButtonVisible = true
                };
            BalanceChart.PopUpContextMenu.Items.AddRange(GetBalanceChartContextMenuItems());
            BalanceChart.MouseMove += SmallBalanceChartMouseMove;
            BalanceChart.MouseLeave += SmallBalanceChartMouseLeave;
            BalanceChart.MouseUp += SmallBalanceChart_MouseUp;
            toolTip.SetToolTip(BalanceChart, Language.T("Click to view the full chart.") +
                                             Environment.NewLine +
                                             Language.T("Right click to detach chart."));

            PanelAccount.Resize += PnlAccountResize;
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        public IndicatorDialog(int slotNumb, SlotTypes slotType, bool isDefined)
        {
            slot          = slotNumb;
            this.slotType = slotType;

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

            TrvIndicators = new TreeView();
            BalanceChart  = new SmallBalanceChart();
            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];
            AFancyNudNumeric    = new FancyNud[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 += TrvIndicatorsNodeMouseDoubleClick;
            TrvIndicators.KeyPress             += TrvIndicatorsKeyPress;

            PnlParameters.Parent = this;

            // pnlSmallBalanceChart
            BalanceChart.Parent = this;

            // lblIndicatorInfo
            LblIndicatorInfo.Parent          = PnlParameters;
            LblIndicatorInfo.Size            = new Size(16, 16);
            LblIndicatorInfo.BackColor       = Color.Transparent;
            LblIndicatorInfo.BackgroundImage = Resources.information;
            LblIndicatorInfo.Click          += LblIndicatorInfoClick;
            LblIndicatorInfo.MouseEnter     += LabelMouseEnter;
            LblIndicatorInfo.MouseLeave     += LabelMouseLeave;

            // lblIndicatorWarning
            LblIndicatorWarning.Parent          = PnlParameters;
            LblIndicatorWarning.Size            = new Size(16, 16);
            LblIndicatorWarning.BackColor       = Color.Transparent;
            LblIndicatorWarning.BackgroundImage = Resources.warning;
            LblIndicatorWarning.Visible         = false;
            LblIndicatorWarning.Click          += LblIndicatorWarningClick;
            LblIndicatorWarning.MouseEnter     += LabelMouseEnter;
            LblIndicatorWarning.MouseLeave     += LabelMouseLeave;

            // 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
            {
                Parent    = PnlParameters,
                TextAlign = ContentAlignment.BottomCenter,
                ForeColor = LayoutColors.ColorControlText,
                BackColor = Color.Transparent
            };

            // ComboBox ACbxList[0]
            ACbxList[0] = new ComboBox {
                Parent = PnlParameters, DropDownStyle = ComboBoxStyle.DropDownList
            };
            ACbxList[0].SelectedIndexChanged += ParamChanged;

            // Logical Group
            LblGroup = new Label
            {
                Parent    = PnlParameters,
                TextAlign = ContentAlignment.BottomCenter,
                ForeColor = LayoutColors.ColorControlText,
                BackColor = Color.Transparent,
                Text      = Language.T("Group")
            };

            CbxGroup = new ComboBox {
                Parent = PnlParameters
            };
            if (slotType == SlotTypes.OpenFilter)
            {
                CbxGroup.Items.AddRange(new object[] { "A", "B", "C", "D", "E", "F", "G", "H", "All" });
            }
            if (slotType == SlotTypes.CloseFilter)
            {
                CbxGroup.Items.AddRange(new object[] { "a", "b", "c", "d", "e", "f", "g", "h", "all" });
            }
            CbxGroup.SelectedIndexChanged += GroupChanged;
            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
                {
                    Parent    = PnlParameters,
                    TextAlign = ContentAlignment.BottomCenter,
                    ForeColor = LayoutColors.ColorControlText,
                    BackColor = Color.Transparent
                };

                ACbxList[i] = new ComboBox
                {
                    Parent        = PnlParameters,
                    Enabled       = false,
                    DropDownStyle = ComboBoxStyle.DropDownList
                };
                ACbxList[i].SelectedIndexChanged += ParamChanged;
            }

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

                AFancyNudNumeric[i] = new FancyNud
                {
                    Parent = PnlParameters, TextAlign = HorizontalAlignment.Center, Enabled = false
                };
                AFancyNudNumeric[i].ValueChanged += ParamChanged;
            }

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

            //Button Accept
            BtnAccept.Parent                  = this;
            BtnAccept.Text                    = Language.T("Accept");
            BtnAccept.DialogResult            = DialogResult.OK;
            BtnAccept.Click                  += BtnOkClick;
            BtnAccept.UseVisualStyleBackColor = true;

            //Button Default
            BtnDefault.Parent = this;
            BtnDefault.Text   = Language.T("Default");
            BtnDefault.Click += BtnDefaultClick;
            BtnDefault.UseVisualStyleBackColor = true;

            //Button Help
            BtnHelp.Parent = this;
            BtnHelp.Text   = Language.T("Help");
            BtnHelp.Click += BtnHelpClick;
            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);
                BalanceChart.SetChartData();
                BalanceChart.InitChart();
                BalanceChart.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();
            }

            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());
                }
            }
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        public IndicatorDialog(int slotNumb, SlotTypes slotType, bool isDefined)
        {
            slot = slotNumb;
            this.slotType = slotType;

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

            TrvIndicators = new TreeView();
            BalanceChart = new SmallBalanceChart();
            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];
            AFancyNudNumeric = new FancyNud[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 += TrvIndicatorsNodeMouseDoubleClick;
            TrvIndicators.KeyPress += TrvIndicatorsKeyPress;

            PnlParameters.Parent = this;

            // pnlSmallBalanceChart
            BalanceChart.Parent = this;

            // lblIndicatorInfo
            LblIndicatorInfo.Parent = PnlParameters;
            LblIndicatorInfo.Size = new Size(16, 16);
            LblIndicatorInfo.BackColor = Color.Transparent;
            LblIndicatorInfo.BackgroundImage = Resources.information;
            LblIndicatorInfo.Click += LblIndicatorInfoClick;
            LblIndicatorInfo.MouseEnter += LabelMouseEnter;
            LblIndicatorInfo.MouseLeave += LabelMouseLeave;

            // lblIndicatorWarning
            LblIndicatorWarning.Parent = PnlParameters;
            LblIndicatorWarning.Size = new Size(16, 16);
            LblIndicatorWarning.BackColor = Color.Transparent;
            LblIndicatorWarning.BackgroundImage = Resources.warning;
            LblIndicatorWarning.Visible = false;
            LblIndicatorWarning.Click += LblIndicatorWarningClick;
            LblIndicatorWarning.MouseEnter += LabelMouseEnter;
            LblIndicatorWarning.MouseLeave += LabelMouseLeave;

            // 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
                {
                    Parent = PnlParameters,
                    TextAlign = ContentAlignment.BottomCenter,
                    ForeColor = LayoutColors.ColorControlText,
                    BackColor = Color.Transparent
                };

            // ComboBox ACbxList[0]
            ACbxList[0] = new ComboBox {Parent = PnlParameters, DropDownStyle = ComboBoxStyle.DropDownList};
            ACbxList[0].SelectedIndexChanged += ParamChanged;

            // Logical Group
            LblGroup = new Label
                {
                    Parent = PnlParameters,
                    TextAlign = ContentAlignment.BottomCenter,
                    ForeColor = LayoutColors.ColorControlText,
                    BackColor = Color.Transparent,
                    Text = Language.T("Group")
                };

            CbxGroup = new ComboBox {Parent = PnlParameters};
            if (slotType == SlotTypes.OpenFilter)
                CbxGroup.Items.AddRange(new object[] {"A", "B", "C", "D", "E", "F", "G", "H", "All"});
            if (slotType == SlotTypes.CloseFilter)
                CbxGroup.Items.AddRange(new object[] {"a", "b", "c", "d", "e", "f", "g", "h", "all"});
            CbxGroup.SelectedIndexChanged += GroupChanged;
            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
                    {
                        Parent = PnlParameters,
                        TextAlign = ContentAlignment.BottomCenter,
                        ForeColor = LayoutColors.ColorControlText,
                        BackColor = Color.Transparent
                    };

                ACbxList[i] = new ComboBox
                    {
                        Parent = PnlParameters,
                        Enabled = false,
                        DropDownStyle = ComboBoxStyle.DropDownList
                    };
                ACbxList[i].SelectedIndexChanged += ParamChanged;
            }

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

                AFancyNudNumeric[i] = new FancyNud
                    {Parent = PnlParameters, TextAlign = HorizontalAlignment.Center, Enabled = false};
                AFancyNudNumeric[i].ValueChanged += ParamChanged;
            }

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

            //Button Accept
            BtnAccept.Parent = this;
            BtnAccept.Text = Language.T("Accept");
            BtnAccept.DialogResult = DialogResult.OK;
            BtnAccept.Click += BtnOkClick;
            BtnAccept.UseVisualStyleBackColor = true;

            //Button Default
            BtnDefault.Parent = this;
            BtnDefault.Text = Language.T("Default");
            BtnDefault.Click += BtnDefaultClick;
            BtnDefault.UseVisualStyleBackColor = true;

            //Button Help
            BtnHelp.Parent = this;
            BtnHelp.Text = Language.T("Help");
            BtnHelp.Click += BtnHelpClick;
            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);
                BalanceChart.SetChartData();
                BalanceChart.InitChart();
                BalanceChart.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();
            }

            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());
        }
        /// <summary>
        ///     Initializes the controls in panel pnlOverview
        /// </summary>
        private void InitializeAccount()
        {
            var toolTip = new ToolTip();

            string[] methods = Enum.GetNames(typeof(InterpolationMethod));
            for (int i = 0; i < methods.Length; i++)
            {
                methods[i] = Language.T(methods[i]);
            }

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

            foreach (string method in methods)
            {
                if ((int)g.MeasureString(method, Font).Width > maxWidth)
                {
                    maxWidth = (int)g.MeasureString(method, Font).Width;
                }
            }
            g.Dispose();

            // ComboBox Interpolation Methods
            ComboBoxInterpolationMethod = new ToolStripComboBox
            {
                Name          = "ComboBoxInterpolationMethod",
                AutoSize      = false,
                DropDownStyle = ComboBoxStyle.DropDownList,
                Width         = maxWidth + (int)(18 * Data.HorizontalDlu),
                ToolTipText   = Language.T("Bar interpolation method.")
            };
            foreach (string method in methods)
            {
                ComboBoxInterpolationMethod.Items.Add(method);
            }
            ComboBoxInterpolationMethod.SelectedIndex         = 0;
            ComboBoxInterpolationMethod.SelectedIndexChanged += SelectedIndexChanged;
            ToolStripAccount.Items.Add(ComboBoxInterpolationMethod);

            // Button Comparator
            var tsbtComparator = new ToolStripButton {
                Text = Language.T("Comparator"), Name = "Comparator"
            };

            tsbtComparator.Click      += BtnToolsOnClick;
            tsbtComparator.ToolTipText = Language.T("Compare the interpolating methods.");
            ToolStripAccount.Items.Add(tsbtComparator);

            // Button Scanner
            var tsbtScanner = new ToolStripButton {
                Text = Language.T("Scanner"), Name = "Scanner"
            };

            tsbtScanner.Click      += BtnToolsOnClick;
            tsbtScanner.ToolTipText = Language.T("Perform a deep intrabar scan.") + Environment.NewLine +
                                      Language.T("Quick scan") + " - F6.";
            ToolStripAccount.Items.Add(tsbtScanner);

            // Button Analyzer
            var tsbtAnalyzer = new ToolStripButton {
                Text = Language.T("Analyzer"), Name = "Analyzer"
            };

            tsbtAnalyzer.Click += BtnToolsOnClick;
            ToolStripAccount.Items.Add(tsbtAnalyzer);

            // Info Panel Account Statistics
            InfoPanelAccountStatistics = new InfoPanel {
                Parent = PanelAccount, Dock = DockStyle.Fill
            };

            new Splitter {
                Parent = PanelAccount, Dock = DockStyle.Bottom, BorderStyle = BorderStyle.None, Height = Gap
            };

            // Small Balance Chart
            BalanceChart = new SmallBalanceChart
            {
                Parent                 = PanelAccount,
                Cursor                 = Cursors.Hand,
                Dock                   = DockStyle.Bottom,
                MinimumSize            = new Size(100, 50),
                ShowDynamicInfo        = true,
                IsContextButtonVisible = true
            };
            BalanceChart.PopUpContextMenu.Items.AddRange(GetBalanceChartContextMenuItems());
            BalanceChart.MouseMove  += SmallBalanceChartMouseMove;
            BalanceChart.MouseLeave += SmallBalanceChartMouseLeave;
            BalanceChart.MouseUp    += SmallBalanceChart_MouseUp;
            toolTip.SetToolTip(BalanceChart, Language.T("Click to view the full chart.") +
                               Environment.NewLine +
                               Language.T("Right click to detach chart."));

            PanelAccount.Resize += PnlAccountResize;
        }
        public StrategyProperties()
        {
            PnlAveraging = new FancyPanel(Language.T("Handling of Additional Entry Signals"),
                                          LayoutColors.ColorSlotCaptionBackAveraging);
            PnlAmounts    = new FancyPanel(Language.T("Trading Size"), LayoutColors.ColorSlotCaptionBackAveraging);
            PnlProtection = new FancyPanel(Language.T("Permanent Protection"),
                                           LayoutColors.ColorSlotCaptionBackAveraging);
            BalanceChart = new SmallBalanceChart();

            LblPercent1 = new Label();
            LblPercent2 = new Label();
            LblPercent3 = new Label();

            LblSameDirAction = new Label();
            LblOppDirAction  = new Label();

            CbxSameDirAction             = new ComboBox();
            CbxOppDirAction              = new ComboBox();
            FancyNudMaxOpenLots          = new FancyNud();
            RbConstantUnits              = new RadioButton();
            RbVariableUnits              = new RadioButton();
            FancyNudEntryLots            = new FancyNud();
            FancyNudAddingLots           = new FancyNud();
            FancyNudReducingLots         = new FancyNud();
            LblMaxOpenLots               = new Label();
            LblEntryLots                 = new Label();
            LblAddingLots                = new Label();
            LblReducingLots              = new Label();
            CbxUseMartingale             = new CheckBox();
            FancyNudMartingaleMultiplier = new FancyNud();

            ChbPermaSL        = new CheckBox();
            CbxPermaSLType    = new ComboBox();
            FancyNudPermaSL   = new FancyNud();
            ChbPermaTP        = new CheckBox();
            CbxPermaTPType    = new ComboBox();
            FancyNudPermaTP   = new FancyNud();
            ChbBreakEven      = new CheckBox();
            FancyNudBreakEven = new FancyNud();

            BtnAccept  = new Button();
            BtnDefault = new Button();
            BtnCancel  = new Button();

            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;
            BalanceChart.Parent  = this;
            BalanceChart.SetChartData();

            var toolTip = new ToolTip();

            // 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;
            var sameItems = new[] { Language.T("Nothing"), Language.T("Winner"), Language.T("Add") };

            foreach (string item in sameItems)
            {
                CbxSameDirAction.Items.Add(item);
            }
            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;
            var oppItems = new[]
            { Language.T("Nothing"), Language.T("Reduce"), Language.T("Close"), Language.T("Reverse") };

            foreach (string item in oppItems)
            {
                CbxOppDirAction.Items.Add(item);
            }
            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
            FancyNudMaxOpenLots.Parent = PnlAmounts;
            FancyNudMaxOpenLots.Name   = "nudMaxOpenLots";
            FancyNudMaxOpenLots.BeginInit();
            FancyNudMaxOpenLots.Minimum       = 0.01M;
            FancyNudMaxOpenLots.Maximum       = 100;
            FancyNudMaxOpenLots.Increment     = 0.01M;
            FancyNudMaxOpenLots.Value         = 20;
            FancyNudMaxOpenLots.DecimalPlaces = 2;
            FancyNudMaxOpenLots.TextAlign     = HorizontalAlignment.Center;
            FancyNudMaxOpenLots.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
            FancyNudEntryLots.Parent = PnlAmounts;
            FancyNudEntryLots.Name   = "nudEntryLots";
            FancyNudEntryLots.BeginInit();
            FancyNudEntryLots.Minimum       = 0.01M;
            FancyNudEntryLots.Maximum       = 100;
            FancyNudEntryLots.Increment     = 0.01M;
            FancyNudEntryLots.Value         = 1;
            FancyNudEntryLots.DecimalPlaces = 2;
            FancyNudEntryLots.TextAlign     = HorizontalAlignment.Center;
            FancyNudEntryLots.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
            FancyNudAddingLots.Parent = PnlAmounts;
            FancyNudAddingLots.Name   = "nudAddingLots";
            FancyNudAddingLots.BeginInit();
            FancyNudAddingLots.Minimum       = 0.01M;
            FancyNudAddingLots.Maximum       = 100;
            FancyNudAddingLots.Increment     = 0.01M;
            FancyNudAddingLots.Value         = 1;
            FancyNudAddingLots.DecimalPlaces = 2;
            FancyNudAddingLots.TextAlign     = HorizontalAlignment.Center;
            FancyNudAddingLots.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
            FancyNudReducingLots.Parent = PnlAmounts;
            FancyNudReducingLots.Name   = "nudReducingLots";
            FancyNudReducingLots.BeginInit();
            FancyNudReducingLots.Minimum       = 0.01M;
            FancyNudReducingLots.Maximum       = 100;
            FancyNudReducingLots.Increment     = 0.01m;
            FancyNudReducingLots.DecimalPlaces = 2;
            FancyNudReducingLots.Value         = 1;
            FancyNudReducingLots.TextAlign     = HorizontalAlignment.Center;
            FancyNudReducingLots.EndInit();

            // CheckBox Use Martingale
            CbxUseMartingale.Name      = "cbxUseMartingale";
            CbxUseMartingale.Parent    = PnlAmounts;
            CbxUseMartingale.ForeColor = ColorText;
            CbxUseMartingale.BackColor = Color.Transparent;
            CbxUseMartingale.AutoCheck = true;
            CbxUseMartingale.AutoSize  = true;
            CbxUseMartingale.Checked   = false;
            CbxUseMartingale.Text      = Language.T("Martingale money management multiplier");

            // NumericUpDown Martingale Multiplier
            FancyNudMartingaleMultiplier.Parent = PnlAmounts;
            FancyNudMartingaleMultiplier.Name   = "nudMartingaleMultiplier";
            FancyNudMartingaleMultiplier.BeginInit();
            FancyNudMartingaleMultiplier.Minimum       = 0.01M;
            FancyNudMartingaleMultiplier.Maximum       = 10;
            FancyNudMartingaleMultiplier.Increment     = 0.01m;
            FancyNudMartingaleMultiplier.DecimalPlaces = 2;
            FancyNudMartingaleMultiplier.Value         = 2;
            FancyNudMartingaleMultiplier.TextAlign     = HorizontalAlignment.Center;
            FancyNudMartingaleMultiplier.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.Add(Language.T("Relative"));
            CbxPermaSLType.Items.Add(Language.T("Absolute"));
            CbxPermaSLType.SelectedIndex = 0;

            // NumericUpDown Permanent S/L
            FancyNudPermaSL.Name   = "nudPermaSL";
            FancyNudPermaSL.Parent = PnlProtection;
            FancyNudPermaSL.BeginInit();
            FancyNudPermaSL.Minimum   = 5;
            FancyNudPermaSL.Maximum   = 5000;
            FancyNudPermaSL.Increment = 1;
            FancyNudPermaSL.Value     = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            FancyNudPermaSL.TextAlign = HorizontalAlignment.Center;
            FancyNudPermaSL.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.Add(Language.T("Relative"));
            CbxPermaTPType.Items.Add(Language.T("Absolute"));
            CbxPermaTPType.SelectedIndex = 0;

            // NumericUpDown Permanent Take Profit
            FancyNudPermaTP.Parent = PnlProtection;
            FancyNudPermaTP.Name   = "nudPermaTP";
            FancyNudPermaTP.BeginInit();
            FancyNudPermaTP.Minimum   = 5;
            FancyNudPermaTP.Maximum   = 5000;
            FancyNudPermaTP.Increment = 1;
            FancyNudPermaTP.Value     = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            FancyNudPermaTP.TextAlign = HorizontalAlignment.Center;
            FancyNudPermaTP.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
            FancyNudBreakEven.Parent = PnlProtection;
            FancyNudBreakEven.Name   = "nudBreakEven";
            FancyNudBreakEven.BeginInit();
            FancyNudBreakEven.Minimum   = 5;
            FancyNudBreakEven.Maximum   = 5000;
            FancyNudBreakEven.Increment = 1;
            FancyNudBreakEven.Value     = Data.InstrProperties.IsFiveDigits ? 1000 : 100;
            FancyNudBreakEven.TextAlign = HorizontalAlignment.Center;
            FancyNudBreakEven.EndInit();

            //Button Default
            BtnDefault.Parent = this;
            BtnDefault.Name   = "btnDefault";
            BtnDefault.Text   = Language.T("Default");
            BtnDefault.Click += BtnDefaultClick;
            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;
        }