• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-instrument Strategy

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

    Multi-instrument Strategy

    Hi,
    I am facing some issues while programming my strategy in NT.
    When I try to add an instrument to my strategy I got the following message in the output:
    **NT** The strategy 'xxxXxxx/bf6de4be4ed142c1b19ceb91e3dd45cc' has called the Add() method with an invalid instrument. Either 'XXXYYY' does not exist in the Instrument Manager or the specified exchange has not been configured.
    N.B.: I am trading forex and got the same error for all the instruments.
    Thank you for your help,
    R.E.

    #2
    Does the instrument exist in your instrument manager? Can you make a chart of it?

    Comment


      #3
      Hello snoppss,

      Thank you for your post.

      Can you provide the full line of code for Add() in your Intialize() method?
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        Hi,
        Thank you for your answer,
        So, the code of my add command is lines like:
        Add("EURUSD",PeriodType.Minute, period);
        In normal time, I can draw the chart of the EURUSD, that's why I use now only this currency, but when I tried to make a chart of it now, it refused to show something else than "Loading data...". I don't get the problem, I remove the strategy of the other chart but it got no effect.

        Thank you for your help,
        R.E.

        Comment


          #5
          Hello R.E.,

          Thank you for your response.

          Change the line to Add("$EURUSD",PeriodType.Minute, period);
          Patrick H.NinjaTrader Customer Service

          Comment


            #6
            Hi,
            Thank you guys, it works perfectly now.
            I have a last query how to add the other instruments I need. Should I enter some paramaters, or there is any tutorial?

            Thank you in advance,
            R.E.

            Comment


              #7
              Hello snoppss,

              Thank you for your response.

              You can find information at the following link: http://ninjatrader.com/support/helpG...nstruments.htm

              Examples can be found under Tools > Edit NinjaScript > Strategy > SampleMultiInstrument and SampleMultiTimeframe.
              Last edited by NinjaTrader_PatrickH; 07-28-2015, 11:15 AM.
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                Hi,
                Thank you for your answer, but I still have troubles with the multi-instrument strategy. I don't need in my strategy anything else than the data of the current bar, but I use something like 14 instruments, and I got this weird error:

                Error on calling 'OnBarUpdate' method for indicator 'X': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                the only data I use in my code is:
                ....
                Closes[k][0];
                ....

                I guess that while my strategy work on the historical data it doesn't process simultaneously the data series, and that NT doesn't got all the information needed stored to calculate my formula.
                What can I do with that?

                Thank you in advance,
                R.E.
                Last edited by snoppss; 07-28-2015, 08:06 AM.

                Comment


                  #9
                  Hello snoppss,

                  Thank you for your response.

                  You would need to ensure the data is available before accessing the values. Information on this matter is available at the following link: http://ninjatrader.com/support/forum...ead.php?t=3170

                  Example would be the following:
                  Code:
                  if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
                  return;
                  // ensure both the primary and secondary series have enough data.
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi,
                    thank you for your answer,

                    The problem I face doesn't appear when using the historical data but only when I use the real time data. I tought it was because I use my instruments with differents time periods (5min and 1 min) but now I make it all 5 minutes, but I still have problems with the real time data.

                    Furthermore, I have 11 instruments and when I add this code at the beggining of my indicator ( because it doesn't seems to work with a strategy I switched to an indicator):
                    for(int i=0;i<=11;i++)
                    if(CurrentBars[i]<=10){
                    Plot0.Set(0);
                    return;
                    }
                    Now I have no errors, but I got only an horizontal line with y=0.
                    I also add something to use the good bars in progress but no result.
                    What can I do then to fix the problem?

                    Thank you in advance,
                    R.E.

                    Comment


                      #11
                      Are you still getting that "Error on calling 'OnBarUpdate' method for indicator 'X' " error or is it the plot line at 0 that you are more worried about?

                      It looks like you are setting it to 0 for each iteration of the loop. I don't know what else you're doing in the code to give a better answer for you. More context plz?

                      Comment


                        #12
                        Hello snoppss,

                        Thank you for your response.

                        May we review your code on our end? If you prefer you can send it to platformsupport[at]ninjatrader[dot]com with this thread in reference: "http://ninjatrader.com/support/forum/showthread.php?t=76629"
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you guys for your help,
                          I simplified a lot my code, so now I simply add 11 instruments to the chart (I think there is some trouble with that), and in the onBarUpdate method I simply verify that it is the first instrument (BarsInProgress==0) and then there is enough data (however I don't use the past data). At the end I just plot one of the instruments close value. But I still have this 0-line drawed.

                          I sent the code in the mail as specified.
                          N.B.: If we remove some lines the code seems to work but it is an impression because if we want some minutes the chart disappears.

                          Thank you in advance,
                          R.E.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by ksarin, Today, 12:39 PM
                          3 responses
                          9 views
                          0 likes
                          Last Post NinjaTrader_PatrickG  
                          Started by ttodua, Today, 12:03 PM
                          1 response
                          6 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by tomtr27, Today, 11:35 AM
                          1 response
                          9 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by Uregon, Today, 07:30 AM
                          2 responses
                          12 views
                          0 likes
                          Last Post bltdavid  
                          Started by Induna, 02-20-2020, 05:38 AM
                          4 responses
                          26 views
                          0 likes
                          Last Post NinjaTrader_Kate  
                          Working...
                          X