i have the following problem in the backtesting:
When i use a SetTrailStop without MTF, the trailing stop works fine.
When i add a second timeframe in the strategy, the trailing stop no longer works correct on the primary time frame.
What make i wrong? I note this NT information:
Should you call this method to dynamically change the trail stop price in the strategy OnBarUpdate() method, you should always reset the trail stop price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your trail stop order on your next open position
How can i reset the trail stop price/offset value?
Example trail stop without MTF: - working fine
----------------------------------------------------------------------------------------------------------
protected override void Initialize()
{
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if(CCI(20)[0] > 200 && Position.MarketPosition == MarketPosition.Flat)
{
EnterLong(DefaultQuantity, "OpenLong");
SetTrailStop("OpenLong", CalculationMode.Ticks, 20, true);
}
}
Example trail stop with MTF: - not work
----------------------------------------------------------------------------------------------------------
protected override void Initialize()
{
CalculateOnBarClose = true;
Add(PeriodeType.Minute, 3);
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
return;
if(CCI(BarsArray[0], 20)[0] > 200 && Positions[0].MarketPosition == MarketPosition.Flat)
{
EnterLong(0, DefaultQuantity, "OpenLong");
SetTrailStop("OpenLong", CalculationMode.Ticks, 20, true);
}
}
Many thanks in advance.

Comment