void GenerateIndicatorParameters(int slot)
{
string indicatorName = Data.Strategy.Slot[slot].IndicatorName;
SlotTypes slotType = Data.Strategy.GetSlotType(slot);
Indicator indicator = Indicator_Store.ConstructIndicator(indicatorName, slotType);
// List parameters
foreach (ListParam list in indicator.IndParam.ListParam)
if (list.Enabled)
{
do
{
list.Index = random.Next(list.ItemList.Length);
list.Text = list.ItemList[list.Index];
} while (list.Caption == "Base price" && (list.Text == "High" || list.Text == "Low"));
}
int firstBar = 0;
do
{
// Numeric parameters
foreach (NumericParam num in indicator.IndParam.NumParam)
if (num.Enabled)
{
if (num.Caption == "Level" && !indicator.IndParam.ListParam[0].Text.Contains("Level"))
continue;
if (!chbUseDefaultIndicatorValues.Checked)
{
double step = Math.Pow(10, -num.Point);
double minimum = num.Min;
double value = num.Min;
double maximum = num.Max;
if (maximum > Data.Bars / 3 && ((num.Caption.ToLower()).Contains("period") ||
(num.Caption.ToLower()).Contains("shift") ||
(num.ToolTip.ToLower()).Contains("period")))
{
maximum = Math.Max(minimum + step, Data.Bars / 3);
}
value = minimum + step * random.Next((int)((maximum - minimum) / step));
num.Value = Math.Round(value, num.Point);
}
}
if (!CalculateIndicator(slotType, indicator))
return;
firstBar = 0;
foreach (IndicatorComp comp in indicator.Component)
if (comp.FirstBar > firstBar)
firstBar = comp.FirstBar;
} while (firstBar > Data.Bars - 10);
//Set the Data.Strategy
IndicatorSlot indSlot = Data.Strategy.Slot[slot];
indSlot.IndicatorName = indicator.IndicatorName;
indSlot.IndParam = indicator.IndParam;
indSlot.Component = indicator.Component;
indSlot.SeparatedChart = indicator.SeparatedChart;
indSlot.SpecValue = indicator.SpecialValues;
indSlot.MinValue = indicator.SeparatedChartMinValue;
indSlot.MaxValue = indicator.SeparatedChartMaxValue;
indSlot.IsDefined = true;
return;
}