Two entry issues with strategy

Hy everyone, I have two entry issues with my strategy and hope someone can help me with it. My strategy is quite simple. If (fast ema > slow Ema and price crossabove my indicator value) or (price > my indicator value and fast ema crossabove slowema)–> go long and the other way around go short. My strategy is running on 10 minute bars with calculation.mode: OneachTick.
My two problems are:

  1. Sometimes the strategy is entering immediately after starting although my trigger was some bars ago. The strategy is set to Wait until flat. I’ve already added "if (State==State.Historical) return; but this doesn’t help.
  2. Sometimes the strategy doesnt open trades although it should have triggered in my point of view. Enclosed you can see a sample of my strategy:
protected override void OnBarUpdate() 
{ 
           if (CurrentBar < Math.Max(FastEmaPeriod, SlowEmaPeriod)) 
              return; 
           if (State ==State.Historical) 
               return;  
           double fastVal = EMA(Close, FastEmaPeriod)[0]; 
           double slowVal = EMA(Close, SlowEmaPeriod)[0]; 

           // Bedingungen 
             longCond = (fastVal > slowVal && CrossAbove(Close, my_indicator,1)||Close[0]>my_indicator[0] && CrossAbove(EMA(Inputs[0], FastEmaPeriod),EMA(Inputs[0], SlowEmaPeriod), 1))); 
             shortCond = (fastVal < slowVal && CrossBelow(Close, my_indicator,1)||(Close[0]<my_indicator[0] && CrossBelow(EMA(Inputs[0], FastEmaPeriod),EMA(Inputs[0], SlowEmaPeriod), 1))); 

           // Entry-Logik 
            if (Position.MarketPosition == MarketPosition.Flat && ((NinjaScriptBase)this).Times[0][1].TimeOfDay > Start.TimeOfDay && ((NinjaScriptBase)this).Times[0][1].TimeOfDay < Stoptime.TimeOfDay) 
            { 
                if (longCond && signalState != 1) 
                { 
                   if (currentDayProfit > DailyLoss && currentDayProfit < DailyProfit) 
                   { 
                      EnterLong(Quantity); 
                      signalState = 1; 
                      protectiveOrdersSet = false; 
                   } 
                } 
                else if (shortCond && signalState != -1) 
               { 
                  if (currentDayProfit > DailyLoss && currentDayProfit < DailyProfit) 
                 { 
                      EnterShort(Quantity); 
                      signalState = -1; 
                      protectiveOrdersSet = false; 
                 } 
               } 
            }
    if (Position.MarketPosition == MarketPosition.Long) 
    { 
     if (currentDayProfit > DailyLoss && currentDayProfit < DailyProfit) 
      { 
                      ExitLong(Quantity); 
      } 
    } 
    else if (Position.MarketPosition == MarketPosition.Short) 
    { 
     if (currentDayProfit > DailyLoss && currentDayProfit < DailyProfit) 
      { 
                      ExitShort(Quantity); 
      } 
    } 
   // Reset-Logik 
  if (Position.MarketPosition == MarketPosition.Flat && signalState == 1 && (CrossBelow(EMA(Inputs[0], FastEmaPeriod),EMA(Inputs[0], SlowEmaPeriod),1) || CrossBelow(Close, my_indicator,1))) 
                 signalState = 0; 
  else if (Position.MarketPosition == MarketPosition.Flat && signalState == -1 && (CrossAbove(EMA(Inputs[0], FastEmaPeriod),EMA(Inputs[0], SlowEmaPeriod),1) || CrossAbove(Close,my_indicator,1))) 
                 signalState = 0;