Following this sample, I've configured my default bars to 5min, and my secondary to 1min. Then, by adding some debug prints, I've noticed that:
- The entry orders are sent and filled in the timeframe of 1 min - as expected
- The Stoploss and Profit target are filled in the 5 minutes time frame, resulting in inaccuracy
In the log excerpt below, you can see that the limit order was placed at 18:05 (OK), Filled at 18:08 (OK), and Stop-Limited at 18:10 (wrong - should be 18:12).
You can find my code below:
protected override void Initialize()
{
Add(PeriodType.Minute, 1);
CalculateOnBarClose = true;
SetProfitTarget(CalculationMode.Ticks, 2);
SetStopLoss(CalculationMode.Ticks, 2);
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
entryLimit = Close[0];
EnterLongLimit(1, true, 1, entryLimit, "Enter long limit: 1min");
}
Print(String.Format("[{0}] {1} {2}: LP = {3}, O = {4}, H = {5}, C = {6}, L = {7}",
(BarsInProgress == 0) ? 5 : 1,
Time[0].ToString(@"dd/MM/yyyy HH:mm:ss"),
"OnBarUpdate",
entryLimit,
Open[0],
High[0],
Close[0],
Low[0]
));
}
[1] 03/01/2011 18:05:00 Fill.Buy 1 Limit @ 1.3344: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3345, NL = 1.3344
[1] 03/01/2011 18:05:00 OnBarUpdate: LP = 1.3344, O = 1.3343, H = 1.3344, C = 1.3344, L = 1.3343
[1] 03/01/2011 18:05:00 Fill.Buy 1 Limit @ 1.3344: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3345, NL = 1.3344
[1] 03/01/2011 18:06:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3345, C = 1.3345, L = 1.3344
[1] 03/01/2011 18:06:00 Fill.Buy 1 Limit @ 1.3344: FP = 0, NO = 1.3344, NH = 1.3344, NC = 1.3344, NL = 1.3344
[1] 03/01/2011 18:07:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3344, C = 1.3344, L = 1.3344
[1] 03/01/2011 18:07:00 Fill.Buy 1 Limit @ 1.3344: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3345, NL = 1.3344
[1] 03/01/2011 18:08:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3345, C = 1.3345, L = 1.3344
[1] 03/01/2011 18:08:00 Fill.Buy 1 Limit @ 1.3344: FP = 1.3344, NO = 1.3344, NH = 1.3344, NC = 1.3344, NL = 1.3343
[5] 03/01/2011 18:05:00 OnExecution: Ex = Enter long limit: 1min
[5] 03/01/2011 18:05:00 OnPositionUpdate: Pr = 1.3344, Pos = Long
[5] 03/01/2011 18:05:00 Fill.Sell 1 Stop @ 1.3342: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3344, NL = 1.3343
[5] 03/01/2011 18:05:00 Fill.Sell 1 Limit @ 1.3346: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3344, NL = 1.3343
[1] 03/01/2011 18:09:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3344, C = 1.3344, L = 1.3343
[5] 03/01/2011 18:05:00 Fill.Sell 1 Stop @ 1.3342: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3344, NL = 1.3343
[5] 03/01/2011 18:05:00 Fill.Sell 1 Limit @ 1.3346: FP = 0, NO = 1.3344, NH = 1.3345, NC = 1.3344, NL = 1.3343
[5] 03/01/2011 18:10:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3345, C = 1.3344, L = 1.3343
[5] 03/01/2011 18:10:00 Fill.Sell 1 Stop @ 1.3342: FP = 1.3342, NO = 1.3343, NH = 1.3345, NC = 1.3345, NL = 1.3342
[5] 03/01/2011 18:10:00 OnExecution: Ex = Stop loss
[5] 03/01/2011 18:10:00 OnPositionUpdate: Pr = 0, Pos = Flat
[1] 03/01/2011 18:10:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3344, C = 1.3344, L = 1.3344
[1] 03/01/2011 18:11:00 OnBarUpdate: LP = 1.3344, O = 1.3343, H = 1.3344, C = 1.3344, L = 1.3343
[1] 03/01/2011 18:12:00 OnBarUpdate: LP = 1.3344, O = 1.3343, H = 1.3344, C = 1.3344, L = 1.3342
[1] 03/01/2011 18:13:00 OnBarUpdate: LP = 1.3344, O = 1.3344, H = 1.3344, C = 1.3344, L = 1.3344
[1] 03/01/2011 18:14:00 OnBarUpdate: LP = 1.3344, O = 1.3343, H = 1.3345, C = 1.3345, L = 1.3342

Comment