public override void Calculate(SlotTypes slotType)
{
// Reading the parameters
int iYear = (int)IndParam.NumParam[0].Value;
int iMonth = (int)IndParam.NumParam[1].Value;
DateTime dtKeyDate = new DateTime(iYear, iMonth, 1);
// Calculation
int iFirstBar = 0;
double[] adBars = new double[Bars];
// Calculation of the logic.
switch (IndParam.ListParam[0].Text)
{
case "Do not open positions after":
for (int iBar = iFirstBar; iBar < Bars; iBar++)
if (Time[iBar] < dtKeyDate)
adBars[iBar] = 1;
break;
case "Do not open positions before":
for (int iBar = iFirstBar; iBar < Bars; iBar++)
{
if (Time[iBar] >= dtKeyDate)
{
iFirstBar = iBar;
break;
}
}
iFirstBar = (int)Math.Min(iFirstBar, Bars - Configs.MIN_BARS);
for (int iBar = iFirstBar; iBar < Bars; iBar++)
{
adBars[iBar] = 1;
}
break;
default:
break;
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp();
Component[0].CompName = "Allow Open Long";
Component[0].DataType = IndComponentType.AllowOpenLong;
Component[0].ChartType = IndChartType.NoChart;
Component[0].ShowInDynInfo = false;
Component[0].FirstBar = iFirstBar;
Component[0].Value = adBars;
Component[1] = new IndicatorComp();
Component[1].CompName = "Allow Open Short";
Component[1].DataType = IndComponentType.AllowOpenShort;
Component[1].ChartType = IndChartType.NoChart;
Component[1].ShowInDynInfo = false;
Component[1].FirstBar = iFirstBar;
Component[1].Value = adBars;
return;
}