So, to help improve my understanding of multi instrument, can you please explain to me what's happening here. I run this stragegy in the optimiser and supply two values - 1 and 2. Each value causes initialize to add a different instrument series, but the results are that each run gets the same prices (see output at end)
Please don't just say the optimizer is not designed to work this way! I'd like to understand what's going on.
[as an aside question, when you have multi instrument, and the primary instrument has no more bars available, will the strategy stop even if the secondary instrument has some more bars?]
thanks
Dave
namespace NinjaTrader.Strategy
{
public class test2 : Strategy
{
private int instIndex;
private string inst;
protected override void Initialize()
{
if (instIndex == 1) {
Add("6J 09-09", PeriodType.Minute, 1);
}
else {
Add("FGBM 09-09", PeriodType.Minute, 1);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1) {
if (Close[0] == 116.76) {
Print ("Index = "+InstIndex+" "+Time[0].ToString()+" "+Close[0].ToString("####.#####"));
}
}
}
[Description("InstIndex")]
[Category("Parameters")]
public int InstIndex
{
get { return instIndex; }
set { instIndex = value; }
}
}
}
[output]
Index = 1 04/09/2009 14:53:00 116.76
Index = 1 04/09/2009 14:57:00 116.76
Index = 1 04/09/2009 15:00:00 116.76
Index = 1 04/09/2009 15:12:00 116.76
Index = 1 04/09/2009 15:15:00 116.76
Index = 1 04/09/2009 15:16:00 116.76
Index = 1 04/09/2009 15:17:00 116.76
Index = 1 04/09/2009 15:18:00 116.76
Index = 1 04/09/2009 15:19:00 116.76
Index = 1 04/09/2009 15:20:00 116.76
Index = 1 04/09/2009 15:28:00 116.76
Index = 1 04/09/2009 15:30:00 116.76
Index = 1 04/09/2009 15:31:00 116.76
Index = 1 04/09/2009 15:33:00 116.76
Index = 1 04/09/2009 15:34:00 116.76
Index = 2 04/09/2009 14:53:00 116.76
Index = 2 04/09/2009 14:57:00 116.76
Index = 2 04/09/2009 15:00:00 116.76
Index = 2 04/09/2009 15:12:00 116.76
Index = 2 04/09/2009 15:15:00 116.76
Index = 2 04/09/2009 15:16:00 116.76
Index = 2 04/09/2009 15:17:00 116.76
Index = 2 04/09/2009 15:18:00 116.76
Index = 2 04/09/2009 15:19:00 116.76
Index = 2 04/09/2009 15:20:00 116.76
Index = 2 04/09/2009 15:28:00 116.76
Index = 2 04/09/2009 15:30:00 116.76
Index = 2 04/09/2009 15:31:00 116.76
Index = 2 04/09/2009 15:33:00 116.76
Comment