Forex_Strategy_Builder.Backtester.EntryLogicConditions C# (CSharp) Method

EntryLogicConditions() static private method

checks if the opening logic conditions allow long or short entry.
static private EntryLogicConditions ( int bar, string group, double buyPrice, double sellPrice, bool &canOpenLong, bool &canOpenShort ) : void
bar int
group string
buyPrice double
sellPrice double
canOpenLong bool
canOpenShort bool
return void
        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;
                        }
                    }
                }
            }
        }