Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multi Instrument Indie inputs dont work unless dataseries is added to charting window

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

    Multi Instrument Indie inputs dont work unless dataseries is added to charting window

    I am brand new to ninjascript (not programming) and decided for my first indicator I'd build a forex currency strength indicator. So I added the various instruments via the Add method in overridden Initialize method.

    So when I load the indicator on the chart nothing shows up. Then I add the vairous other instruments to the chart, and when the indie has enough data is starts plotting correctly.

    My question is, why isnt the indicator grabbing the data for the other instruments when loaded on a single chart?

    protected override void Initialize()
    {
    Add("$AUDUSD", PeriodType.Minute, 1);
    Add("$EURCHF", PeriodType.Minute, 1);
    Add("$EURGBP", PeriodType.Minute, 1);

    and so on. So I actually need to add a AUDUSD, EURCHF, and EURGBP chart to the same window in order for Closes[idx][0] to read for these pairs or BarsInProgress to indicate data from one of the above pairs.

    Is there something I'm missing?

    I have seen other indicators that use multiple instruments loaded on a single chart (screenshots).

    Thanks!

    #2
    Hello ctTrading,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    That should not be the case, the data should be downloaded when you add it via Initialize(). So I may investigate this matter further please answer the following questions.
    • What version of NinjaTrader are you using? You can check under Help -> About (Example: 7.0.1000.26)
    • Who are you connected to? This is displayed by green on lower left corner of the Control Center window.
    • Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

    I look forward to your response.

    Comment


      #3
      Ninjatrader 7.0.1000.26

      Thanks for the quick reponse!

      Ninjatrader 7.0.1000.26
      Connected - FXCM

      No errors are displayed.

      If I go to data series->add new forexsymbols and add the ones this inidcator relies on then it works.

      Comment


        #4
        Appologies, I was looking for errors in the chart. The log is showing errors:

        Default:
        "Error on calling 'OnBarUpdate' method for indicaor ForexStrengthMeter' on bar 0: You are accessing and index with a value that is invalid since its out of range. I.E. access a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

        Comment


          #5
          Hello ctTrading,

          Are you adding any CurrentBars check at the beginning of the OnBarUpdate()?
          For information on CurrentBars please visit the following link: http://www.ninjatrader.com/support/h...urrentbars.htm
          For more information on ensuring you have enough bars before accessing them please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

          Comment


            #6
            Ok great, I added 28 instruments then this in the top of OnBarUpdate

            int indexes = 28;
            while (indexes > 0) {
            if (CurrentBars[indexes] < _minBars){
            return;
            }
            indexes--;
            }

            Working well now. I do have a followup question though.

            Since I have 28 instruments feeding data in one minute increments, should I use BarsInProgress to identify the correct pair (1-28) and do my calculations for the pairs that instrument would effect?

            I ask because if the data comes in in the order of subscribed instruments then I can just check for BarsInProgress == 28 and do one set of calculations per minute vs doing 28-56 per minute.

            But what I can't have, is old bars in my calculation. So if the 28th instrument triggers the calculation before the other 27 have time to get fresh bars in I'll be using the last minutes data.

            I'm sorry if this isn't terribly clear, let me know and I can explain further.

            Comment


              #7
              Hello ctTrading,

              Thank you for your response.

              Checking BarsInProgress before running calculations would make since. However, are you calling other bar series when running calculations for another? For example:
              Code:
              if(Closes[0][0] > Closes[1][0])

              Comment


                #8
                Hi ctTrading,

                I am try to built a weighted composite index could you help me ?
                Also I would like to weight the indicators of 10 stocks, do you know how to do that ?

                thank you so much,

                Comment


                  #9
                  Hello cbahia,

                  You can take a look at the WMA in NinjaTrader for an example on weighting values. Please go to Tools > Edit NinjaScript > Indicator > WMA > OK.

                  Comment


                    #10
                    thank you.....

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by mattbsea, Today, 05:44 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post mattbsea  
                    Started by RideMe, 04-07-2024, 04:54 PM
                    6 responses
                    31 views
                    0 likes
                    Last Post RideMe
                    by RideMe
                     
                    Started by tkaboris, Today, 05:13 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post tkaboris  
                    Started by GussJ, 03-04-2020, 03:11 PM
                    16 responses
                    3,282 views
                    0 likes
                    Last Post Leafcutter  
                    Started by WHICKED, Today, 12:45 PM
                    2 responses
                    20 views
                    0 likes
                    Last Post WHICKED
                    by WHICKED
                     
                    Working...
                    X