I'm trying to set up a trailing type stop where once a certain price is reached, the stop will trail one tick above the high/low of the previous bar. My initial entry, stop, and profit targets are all working correctly, but the stop adjustment didn't work at all... CaculateOnBarClose = false
My code for the trailing stop is:
if ((Position.MarketPosition == MarketPosition.Short) && (trail == 1) && (FirstTickOfBar))
{
SetStopLoss(CalculationMode.Price, High[1] + TickSize);
}
if ((Position.MarketPosition == MarketPosition.Short) && (trail == 0) && (Close[0] == trailtarget))
{
SetStopLoss(CalculationMode.Price, High[1] + TickSize);
trail = 1;
}
Execution completely ignored adjusting the stop, but the logic seems correct from what I see. Should I be using the ExitShortStop instead of SetStopLoss function? If that's the case, does it still leave the initial stop in place until the position is exited? Is there a way to just move the initial stop rather than having a 2nd one trailing along? Or maybe I'm misunderstanding something. trailtarget is assigned along with the initial order entry as Close[0] - value, and trail = 0 as well.
Comment