example im in a short position on NQ. as the trade open i want to place a limit order on the ES $400 below the close of the last bar with a trailing stop and no profit target.
running the current code the hedge positions are not being trigger properly and are being executed when they should not have been hit?
anyone that could help me do this the right way. i would be appreciated , im new to coding
here is the code:
// enter long position based on the trend confirmation
if (isPivotConfirmTrend1)
{
EnterLong();
SetStopLoss(CalculationMode.Currency, atrStop);
SetProfitTarget(CalculationMode.Currency, profitTarget);
// add a limit order with a trailing stop and no profit target in the opposite direction to hedge the position
double limitPrice = Close[0] - HedgeOffset;
EnterShortLimit(1, true, DefaultQuantity, limitPrice, "HedgeOrder");
SetTrailStop("HedgeOrder", CalculationMode.Currency, TrailStopSize, false);
}
// enter short position based on the trend confirmation
else if (isPivotConfirmTrend2)
{
EnterShort();
SetStopLoss(CalculationMode.Currency, atrStop);
SetProfitTarget(CalculationMode.Currency, profitTarget);
// add a limit order with a trailing stop and no profit target in the opposite direction to hedge the position
double limitPrice = Close[0] + HedgeOffset;
EnterLongLimit(1, true, DefaultQuantity, limitPrice, "HedgeOrder");
SetTrailStop("HedgeOrder", CalculationMode.Currency, TrailStopSize, false);
}
Comment