I have this piece of code in my strategy, in order to change my trailing stop when price goes in my favour.
// Resets the trail stop to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetTrailStop(CalculationMode.Ticks, trailstop);
}
// Condition set 2
if (Position.MarketPosition == MarketPosition.Long
&& Close[0] > Position.AvgPrice + 50 * TickSize)
{
SetTrailStop(CalculationMode.Ticks, trailstop + 10);
}
// Condition set 4
if (Position.MarketPosition == MarketPosition.Short
&& Close[0] < Position.AvgPrice - 50 * TickSize)
{
SetTrailStop(CalculationMode.Ticks, trailstop + 10);
}
This seems to work fine in backtests. But it's not working when running the strategy on real time, the trailing stop do not change. Any ideas why this is happening?
Thanks!
Comment