/// <summary> /// Sets the parameters /// </summary> void SetIndicatorParams() { int checkedChBoxes = 0; // Counts the strategy's numeric parameters and Indicators indicators = 0; parameters = 0; int indicatorSlot = -1; for (int slot = 0; slot < Data.Strategy.Slots; slot++) for (int numParam = 0; numParam < 6; numParam++) if (Data.Strategy.Slot[slot].IndParam.NumParam[numParam].Enabled) { parameters++; if (indicatorSlot != slot) { indicatorSlot = slot; indicators++; } } aParameter = new Parameter[parameters]; achbxParameterName = new CheckBox[parameters]; alblParameterValue = new Label[parameters]; anudParameterMin = new NumericUpDown[parameters]; anudParameterMax = new NumericUpDown[parameters]; anudParameterStep = new NumericUpDown[parameters]; alblIndicatorName = new Label[parameters]; // Fill the lines indicatorSlot = -1; int param = 0; for (int slot = 0; slot < Data.Strategy.Slots; slot++) { for (int numParam = 0; numParam < 6; numParam++) { if (Data.Strategy.Slot[slot].IndParam.NumParam[numParam].Enabled) { if (indicatorSlot != slot) { indicatorSlot = slot; alblIndicatorName[param] = new Label(); alblIndicatorName[param].Parent = pnlParams; alblIndicatorName[param].Text = Data.Strategy.Slot[slot].IndicatorName; alblIndicatorName[param].Font = fontIndicator; alblIndicatorName[param].ForeColor = LayoutColors.ColorSlotIndicatorText; alblIndicatorName[param].BackColor = Color.Transparent; alblIndicatorName[param].Height = 18; alblIndicatorName[param].Width = 200; } aParameter[param] = new Parameter(slot, numParam); achbxParameterName[param] = new CheckBox(); achbxParameterName[param].ForeColor = colorText; achbxParameterName[param].BackColor = Color.Transparent; achbxParameterName[param].Text = aParameter[param].ParameterName; achbxParameterName[param].CheckedChanged += new EventHandler(Optimizer_CheckedChanged); // Auto checked if (Data.Strategy.Slot[slot].IndParam.NumParam[numParam].Caption == "Level") { if (Data.Strategy.Slot[slot].IndParam.ListParam[0].Text.Contains("Level")) { if (random.Next(100) > 20 && checkedChBoxes < 6) { achbxParameterName[param].Checked = true; checkedChBoxes++; } } else { achbxParameterName[param].Checked = false; } } else { if (random.Next(100) > 40 && checkedChBoxes < 6) { achbxParameterName[param].Checked = true; checkedChBoxes++; } } int point = aParameter[param].Point; double value = aParameter[param].Value; double min = aParameter[param].Minimum; double max = aParameter[param].Maximum; double step = Math.Round(Math.Pow(10, -point), point); string stringFormat = "{0:F" + point.ToString() + "}"; alblParameterValue[param] = new Label(); alblParameterValue[param].ForeColor = colorText; alblParameterValue[param].BackColor = Color.Transparent; alblParameterValue[param].Text = string.Format(stringFormat, value); fontParamValueRegular = alblParameterValue[param].Font; fontParamValueBold = new Font(fontParamValueRegular, FontStyle.Bold); anudParameterMin[param] = new NumericUpDown(); anudParameterMin[param].BeginInit(); anudParameterMin[param].Minimum = (decimal)min; anudParameterMin[param].Maximum = (decimal)max; anudParameterMin[param].Value = (decimal)Math.Round(Math.Max(value - 5 * step, min), point); anudParameterMin[param].DecimalPlaces = point; anudParameterMin[param].Increment = (decimal)step; anudParameterMin[param].EndInit(); toolTip.SetToolTip(anudParameterMin[param], Language.T("Minimum value.")); anudParameterMax[param] = new NumericUpDown(); anudParameterMax[param].BeginInit(); anudParameterMax[param].Minimum = (decimal)min; anudParameterMax[param].Maximum = (decimal)max; anudParameterMax[param].Value = (decimal)Math.Round(Math.Min(value + 5 * step, max), point); anudParameterMax[param].DecimalPlaces = point; anudParameterMax[param].Increment = (decimal)step; anudParameterMax[param].EndInit(); toolTip.SetToolTip(anudParameterMax[param], Language.T("Maximum value.")); anudParameterStep[param] = new NumericUpDown(); anudParameterStep[param].BeginInit(); anudParameterStep[param].Minimum = (decimal)step; anudParameterStep[param].Maximum = (decimal)Math.Max(step, Math.Abs(max - min)); anudParameterStep[param].Value = (decimal)step; anudParameterStep[param].DecimalPlaces = point; anudParameterStep[param].Increment = (decimal)step; anudParameterStep[param].EndInit(); toolTip.SetToolTip(anudParameterStep[param], Language.T("Step of change.")); achbxParameterName[param].Parent = pnlParams; achbxParameterName[param].Width = 140; achbxParameterName[param].TextAlign = ContentAlignment.MiddleLeft; alblParameterValue[param].Parent = pnlParams; alblParameterValue[param].Width = 50; alblParameterValue[param].TextAlign = ContentAlignment.MiddleCenter; anudParameterMin[param].Parent = pnlParams; anudParameterMin[param].Width = 70; anudParameterMin[param].TextAlign = HorizontalAlignment.Center; anudParameterMax[param].Parent = pnlParams; anudParameterMax[param].Width = 70; anudParameterMax[param].TextAlign = HorizontalAlignment.Center; anudParameterStep[param].Parent = pnlParams; anudParameterStep[param].Width = 70; anudParameterStep[param].TextAlign = HorizontalAlignment.Center; param++; } } } pnlParams.Height = (parameters + indicators) * 28 + 25; ArangeControls(); btnOptimize.Focus(); return; }