I have a strategy where I want long trade to be executed when the current candle (isnewhighcandle) makes a new high by two ticks vs the previous candle (pullback candles) if certain conditions (RSI,MACD levels..) are met on the pullback candles. But no matter what i try, it keeps waiting for the isnewhighcandle to close and then executes the trades on the following candle after two ticks. How do I get it to fire on the isnewhighcandle? Calculation is set on eachtick. Below is the relevant section of the code. The execution part is highlighted in black. I can provide full code if needed. I've attached a picture at the end which illustrates the issue as well. The execution should be happening on the candle with the pink arrow around the blue horizontal line; instead it executes one bar later. Thank you:
bool isNewHighCandle = ((isFirstPullbackSeriesLong[1] == 1 && previousRSILong < RsiInitialThresholdLong) ||
(isSubsequentPullbackSeriesLong[1] == 1 && previousRSILong < RsiSubsequentThresholdLong)) &&
High[0] > High[1] &&
(!EnableAdxFilter || previousADXLong > AdxThresholdLong) &&
previousMACDLong > MacdThresholdLong;
isNewHighCandleSeriesLong[0] = isNewHighCandle ? 1 : 0;
if (isNewHighCandle)
{
Draw.ArrowDown(this, "NewHigh" + CurrentBar, false, 0, High[0] + 2 * TickSize, Brushes.Pink);
}
// Execute Long Trade
if (EnableLongTrades && isNewHighCandle && High[0] >= High[1] + 2 * TickSize)
{
Print("Long Entry condition met on bar: " + CurrentBar);
EnterLongStopLimit(NumberOfContracts, High[0] + 2 * TickSize, High[0] + 2 * TickSize, "Long Entry");
SetStopLoss("Long Entry", CalculationMode.Ticks, FixedStopLossTicks, false);
SetProfitTarget("Long Entry", CalculationMode.Ticks, FixedTargetProfitTicks);

Comment