public override void Calculate(SlotTypes slotType)
{
// Reading the parameters
int iFromHour = (int)IndParam.NumParam[0].Value;
int iFromMin = (int)IndParam.NumParam[1].Value;
int iUntilHour = (int)IndParam.NumParam[2].Value;
int iUntilMin = (int)IndParam.NumParam[3].Value;
TimeSpan tsFromTime = new TimeSpan(iFromHour, iFromMin, 0);
TimeSpan tsUntilTime = new TimeSpan(iUntilHour, iUntilMin, 0);
// Calculation
int iFirstBar = 1;
double[] adBars = new double[Bars];
// Calculation of the logic
for (int iBar = iFirstBar; iBar < Bars; iBar++)
{
if(tsFromTime < tsUntilTime)
adBars[iBar] = Time[iBar].TimeOfDay >= tsFromTime &&
Time[iBar].TimeOfDay < tsUntilTime ? 1 : 0;
else if(tsFromTime > tsUntilTime)
adBars[iBar] = Time[iBar].TimeOfDay >= tsFromTime ||
Time[iBar].TimeOfDay < tsUntilTime ? 1 : 0;
else
adBars[iBar] = 1;
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp();
Component[0].CompName = "Is long entry allowed";
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 = "Is short entry allowed";
Component[1].DataType = IndComponentType.AllowOpenShort;
Component[1].ChartType = IndChartType.NoChart;
Component[1].ShowInDynInfo = false;
Component[1].FirstBar = iFirstBar;
Component[1].Value = adBars;
return;
}