static void EntryLogicConditions(int bar, string group, double buyPrice, double sellPrice, ref bool canOpenLong, ref bool canOpenShort)
{
for (int slot = 0; slot < Strategy.CloseSlot + 1; slot++)
{
if (Configs.UseLogicalGroups && Strategy.Slot[slot].LogicalGroup != group && Strategy.Slot[slot].LogicalGroup != "All")
continue;
foreach (IndicatorComp component in Strategy.Slot[slot].Component)
{
if (component.DataType == IndComponentType.AllowOpenLong && component.Value[bar] < 0.5)
canOpenLong = false;
if (component.DataType == IndComponentType.AllowOpenShort && component.Value[bar] < 0.5)
canOpenShort = false;
if (component.PosPriceDependence != PositionPriceDependence.None)
{
double indVal = component.Value[bar - component.UsePreviousBar];
switch (component.PosPriceDependence)
{
case PositionPriceDependence.PriceBuyHigher:
canOpenLong = canOpenLong == true && buyPrice > indVal + micron;
break;
case PositionPriceDependence.PriceBuyLower:
canOpenLong = canOpenLong == true && buyPrice < indVal - micron;
break;
case PositionPriceDependence.PriceSellHigher:
canOpenShort = canOpenShort == true && sellPrice > indVal + micron;
break;
case PositionPriceDependence.PriceSellLower:
canOpenShort = canOpenShort == true && sellPrice < indVal - micron;
break;
case PositionPriceDependence.BuyHigherSellLower:
canOpenLong = canOpenLong == true && buyPrice > indVal + micron;
canOpenShort = canOpenShort == true && sellPrice < indVal - micron;
break;
case PositionPriceDependence.BuyLowerSelHigher:
canOpenLong = canOpenLong == true && buyPrice < indVal - micron;
canOpenShort = canOpenShort == true && sellPrice > indVal + micron;
break;
default:
break;
}
}
}
}
}