I am currently trying to code a strategy that allows me to enter trades using limit orders and also allows for me to reverse direction if there is an opposing direction signal. However, it seems that when I am in a position and there is supposed to be an EnterLongLimit or EnterShortLimit order to switch directions these orders do not place. I've replayed my strategy in Playback mode and have observed the first Limit entry order work but then when the strategy is supposed to reverse the opposing limit order does not get placed. I've also debugged my strategy with print statements to ensure that the if statement logic is properly running for the sections that have the Limit entry orders within them when reversing. As a result, I believe this might have something to do with the order handling rules but am unsure of what the actual issue is.
Here are my two sections of code for the limit entry orders:
Short Entries:
if (UseStopCloseOppWickTargetR && !UseTwoPTLevels)
{
bearTarget = (entryPrice - ((shortCloseStopBodySL - entryPrice) * RProfitMultiplier));
bearTarget2 = (entryPrice - ((shortCloseStopBodySL - entryPrice) * RProfitMultiplier2));
Print("The target price for this trade is: " + bearTarget + " Time: " + Time[0]);
Print("The stop loss for this trade is: " + shortCloseStopBodySL + " Time: " + Time[0]);
SetProfitTarget("Short", CalculationMode.Price, bearTarget);
SetStopLoss("Short", CalculationMode.Ticks, MaxSL, false);
SetProfitTarget("Short2", CalculationMode.Price, bearTarget);
SetStopLoss("Short2", CalculationMode.Ticks, MaxSL, false);
Short1 = EnterShortLimit(0, true, DefaultQuantity, entryPrice, "Short");
Short2 = EnterShortLimit(0, true, DefaultQuantity, entryPrice, "Short2");
shortEntryCandleCount = 0; // Reset the counter when a new short order is placed
}
Long Entries:
if (UseStopCloseOppWickTargetR && !UseTwoPTLevels)
{
bullTarget = (((entryPrice - longCloseStopWickSL) * RProfitMultiplier) + entryPrice);
bullTarget2 = (((entryPrice - longCloseStopWickSL) * RProfitMultiplier2) + entryPrice);
Print("The target price for this trade is: " + bullTarget + " Time: " + Time[0]);
Print("The stop loss for this trade is: " + longCloseStopBodySL + " Time: " + Time[0]);
SetProfitTarget("Long", CalculationMode.Price, bullTarget);
SetStopLoss("Long", CalculationMode.Ticks, MaxSL, false);
SetProfitTarget("Long2", CalculationMode.Price, bullTarget);
SetStopLoss("Long2", CalculationMode.Ticks, MaxSL, false);
Long1 = EnterLongLimit(0, true, DefaultQuantity, entryPrice, "Long");
Long2 = EnterLongLimit(0, true, DefaultQuantity, entryPrice, "Long2");
longEntryCandleCount = 0; // Reset the counter when a new long order is placed
}
Thank you!

Comment