Hello, i have modified and simplified code using ternary operators and for some reason strategy still takes trades against my logic. i am stating not to take short trades if sum of wicks is greater then 4 in last 4 bars. Output prints correct number of ticks in wicks. Maybe i am not using sytax right? Could it be improved? If we look at screenshot we see two short trades first one is right(no wicks) second one is not right (15 tick wicks). LimitWicks is my bool that i am evaluating sum of wicks. Trade34B is the strategy among other strategies. Thank you
&& (Trade34B && LimitWicks ? (LowerSum <= (CumulativeWicks * TickSize)) : Close[0] > 0)
if (Trade34B
&& ((Trade34B == true)
&& (!IsInShortTrade) && (!IsInLongTrade) && (stopOrder == null) && (Position.Quantity == 0)
&& (AngulationOn ? (emaAngulation <= (-EMAAngulation * TickSize)) : Close[0] > 0)
&& (AngulationOn ? (emaAngulationXBarsBefore < (-EMAAngulationXBarsBefore * TickSize)) : Close[0] > 0)
&& (FiveBarRetracement ? ((Close[1] > Open[1]) && (Close[2] > Open[2]) && (Close[3] > Open[3])
&& (Close[4] > Open[4]) && (Close[5] > Open[5])) : Close[0] > 0)
&& (ThreeBarRetracement ? ((Close[1] > Open[1]) && (Close[2] > Open[2]) && (Close[3] > Open[3])) : Close[0] > 0)
&& (High[0] > High[1]) && (High[0] >= slowEMA[0]) && (Close[0] < (slowEMA[0] - ABEMA34B * TickSize) && fastEMA[0] < slowEMA[0])
&& (NoTradeAgainstWick ? (Close[0] < Low[1]) : Close[0] > 0)
&& (FilterEMA ? (filterEMA[0] >= slowEMA[0] && (distancefilterEMAand34 >= (6 * TickSize))) : Close[0] > 0)
&& (MarginToRececntSwingHL ? (marginToRecentSwingL > (MarginToSwing * TickSize)) : Close[0] > 0)
&& (VolumeFilter ? (VOL()[0] > VolumeReading) : Close[0] > 0)
&& (StochFilter ? ((StochasticsFast1.D[0] <= StochLongLevels) && (StochasticsFast1.D[0] >= StochShortLevels)) : Close[0] > 0)
&& (Trade34B && LimitWicks ? (LowerSum <= (CumulativeWicks * TickSize)) : Close[0] > 0)
&& (DistanceSettlement ? (distToSettlment >= (DistToSettlment * TickSize)) : Close[0] > 0)
&& (DeltaClose ? (Deltaclose < Deltaopen) : Close[0] > 0)
&& (DeltaEngulf ? (Deltaclose < Deltaopen) && (Deltaclose < Math.Min(DeltaopenPr, DeltaclosePr)) : Close[0] > 0)
&& (DistanceOHL ? (distToOHLL) > (DistanceToOHL * TickSize) : Close[0] > 0)
&& (BarsSinceExitExecution(0, "", 0) > 2) || (BarsSinceExitExecution(0, "", 0) == -1)
&& (Position.MarketPosition == MarketPosition.Flat)))
{
entryOrder = SubmitOrderUnmanaged(0, OrderAction.SellShort, OrderType.Market, TradeSize, 0, 0, "", "34B");
IsInShortTrade = true;
LastClose = Close[0];
if (SystemPrint == true && Trade34B == true)
{
Print("------------------");
Print("Trade34B SHorts: " + Trade34B + " " + Time[0] + " " + "Sum Lower Wicks " + sumLowerWicks);
Print("DeltaClose " + Deltaclose + " " + "DeltaClosePr " + DeltaclosePr);
Print("------------------");
}
return;
}
if ((UseTrailingStop) && (IsInShortTrade) && (LastClose > Close[0]) && (stopOrder != null) && (Close[0] < CurrentTriggerPrice))
{
//double slL = Instrument.MasterInstrument.RoundToTickSize(Close[0] + (StopLoss * TickSize));
CurrentTriggerPrice = (Close[0] - (TrailFrequency * TickSize)) ;
CurrentStopPrice = (Close[0] - (TrailStopDistance * TickSize)) ;
if(entryOrder != null)ChangeOrder(stopOrder, Position.Quantity, 0, CurrentStopPrice);
LastClose = Close[0];
if(SystemPrint == true && Trade34B == true)
Print("Short 34B Trade Trailing Stop sIL = " + CurrentStopPrice + " Position.Quantity = " + Position.Quantity + " CurrentBar = " + CurrentBar);
}
if ((Position.MarketPosition == MarketPosition.Short)
&& (Close[0] < CurrentTriggerPrice))
{
CurrentTriggerPrice = (Close[0] - (TrailFrequency * TickSize)) ;
CurrentStopPrice = (Close[0] - (TrailStopDistance * TickSize)) ;
}

Comment