Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different instrument per run

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Different instrument per run

    Hi, I realise that this may not sound like the way things are done in NT, but I'm doing it because it's a real pain having to manually run for each instrument and maintain a list of them etc.

    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

    #2
    dave1992, unfortunately it's not supported to dynamically Add an instrument as you have done in the Initialize(). The strategy will run for the time period where all used bars objects have data present.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by RubenCazorla, 08-30-2022, 06:36 AM
    3 responses
    77 views
    0 likes
    Last Post PaulMohn  
    Started by f.saeidi, Yesterday, 12:14 PM
    9 responses
    23 views
    0 likes
    Last Post f.saeidi  
    Started by Tim-c, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Started by FrancisMorro, Today, 03:24 AM
    0 responses
    3 views
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,772 views
    0 likes
    Last Post Leafcutter  
    Working...
    X