Hello,
I have a Renko strategy (MNQ 09-26, 20-brick) that is not triggering exit orders correctly. The strategy uses Calculate.OnEachTick and monitors bar direction using Close[0] > Open[0] and Close[0] < Open[0] to detect Renko box color.
The problem: When in a Long position, the exit condition if (boxNegativo && CurrentBar != ultimoBarSaida) never fires, even when clearly negative (red) Renko bars appear on the chart. I can see red bars visually but no ExitLong order is ever sent — confirmed by checking the Orders tab, which shows zero StopReversaoCompra entries during that period.
What I have tried:
-
Calculate.OnBarClosewithExitLongLimit— exit not guaranteed -
Calculate.OnBarClosewithExitLong(market) — exit still not firing -
Calculate.OnEachTickwithIsFirstTickOfBar— unreliable -
Calculate.OnEachTickwithoutIsFirstTickOfBar— exit still not firing -
OnMarketDataoverride — silently ignored
My questions:
-
Is
Close[0] > Open[0]a reliable way to detect Renko bar direction duringOnEachTick? -
Is
IsFirstTickOfBarreliable with Renko data? -
What is the correct approach to detect when a new Renko bar closes in a different direction while using
Calculate.OnEachTick?
Here is the relevant exit code:
csharp
Calculate = Calculate.OnEachTick;
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade) return;
if (State != State.Realtime) return;
bool boxPositivo = Close[0] > Open[0];
bool boxNegativo = Close[0] < Open[0];
if (Position.MarketPosition == MarketPosition.Long)
{
if (boxNegativo && CurrentBar != ultimoBarSaida)
{
CancelAllOrders();
ExitLong("StopReversaoCompra");
ultimoBarSaida = CurrentBar;
return;
}
}
if (Position.MarketPosition == MarketPosition.Short)
{
if (boxPositivo && CurrentBar != ultimoBarSaida)
{
CancelAllOrders();
ExitShort("StopReversaoVenda");
ultimoBarSaida = CurrentBar;
return;
}
}
}
Any help is greatly appreciated. Thank you!