Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with multi support

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

    Problem with multi support

    Good morning,
    I created an indicator whose calculate an indicator just for test from multi pair forex.
    So I wrote this:
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Add("AUDUSD",PeriodType.Minute, 5);
    Overlay = false;
    }
    I tried with Add("$AUDUSD",PeriodType.Minute, 5); too and the result is same.

    After I wrote this:
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Plot0.Set(CCI(10)[0]/CCI(BarsArray[1],10)[0] );
    }
    And this don't work.
    If I look the error log, I can see this:
    05/01/2013 14:46:05|3|4|The indicator 'MyCompareSerie' has called the Add() method with an invalid instrument. Either 'AUDUSD' does not exist in the Instrument Manager or the specified exchange has not been configured.
    But if I go in the Instrument Manager my pair exist as you see in the file attached. It exit in the forex too.
    Could you explain me please?
    Thank's a lot.
    Attached Files

    #2
    Hello,
    I have advanced now my pair is called, but now I have this problem:
    My code:
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Plot0.Set(EMA(BarsArray[1],10)[0] );
    }
    The problem
    05/01/2013 15:14:04|3|4|Error on calling 'OnBarUpdate' method for indicator 'MyCompareSerie' on bar 0: 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.

    Comment


      #3
      Originally posted by neo-13 View Post
      Hello,
      I have advanced now my pair is called, but now I have this problem:
      My code:
      protected override void OnBarUpdate()
      {
      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      Plot0.Set(EMA(BarsArray[1],10)[0] );
      }
      The problem
      05/01/2013 15:14:04|3|4|Error on calling 'OnBarUpdate' method for indicator 'MyCompareSerie' on bar 0: 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.
      You need to check for validity of BarsArray[1].

      ref: http://www.ninjatrader.com/support/h...urrentbars.htm

      Comment


        #4
        Thank's for your answer,
        I must to be stupid because I'm developpers and I understand nothing about this language.
        If I write:
        Plot0.Set(EMA(BarsArray[0],10)[0] );
        it work
        If I write
        Plot0.Set(EMA(BarsArray[1],10)[0] );
        It don't work with our without your explanation.
        The error is:
        Error on calling 'OnBarUpdate' method for indicator 'MyCompareSerie' on bar 0: 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.

        I used Multichart, tradestation, Prorealtime, metatrader, and It's the first time I meet a language where I can't to program and I don't understand the error. i copy and paste the example of the guideline and don't work.
        Thank's again for your help.

        Comment


          #5
          Originally posted by neo-13 View Post
          Thank's for your answer,
          I must to be stupid because I'm developpers and I understand nothing about this language.
          If I write:
          Plot0.Set(EMA(BarsArray[0],10)[0] );
          it work
          If I write
          Plot0.Set(EMA(BarsArray[1],10)[0] );
          It don't work with our without your explanation.
          The error is:
          Error on calling 'OnBarUpdate' method for indicator 'MyCompareSerie' on bar 0: 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.

          I used Multichart, tradestation, Prorealtime, metatrader, and It's the first time I meet a language where I can't to program and I don't understand the error. i copy and paste the example of the guideline and don't work.
          Thank's again for your help.
          The link that I pointed you to says this, inter alia:
          Code:
          protected override void OnBarUpdate()
          {
              // Checks to make sure we have at least 20 (default value of BarsRequired)
              // or more bars in both Bars objects before continuing.
              if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
                 return;
           
              // Script logic calculation code...
          }
          Emphasis mine in bold red.

          I wonder if you even bothered to check the link, as code is pretty much half the page?

          Comment


            #6
            Thank's for your answer,
            sorry but I'm french and I don't understand very well english.
            I wrote your code but it don't work:
            protected override void OnBarUpdate()
            {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
            return;
            Plot0.Set(EMA(BarsArray[0],10)[0] );
            }
            There is no compil error but I don't have indic on my graph.

            The complet code:
            public class MyCompareSerie : Indicator
            {
            #region Variables
            // Wizard generated variables
            private int lenght = 20; // Default setting for Lenght
            // User defined variables (add any user defined variables below)
            #endregion

            /// <summary>
            /// This method is used to configure the indicator and is called once before any bar data is loaded.
            /// </summary>
            protected override void Initialize()
            {
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
            Add("$EURAUD",PeriodType.Minute, 5);
            //Add("$AUDUSD",PeriodType.Minute, 5);
            Overlay = false;
            }

            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
            return;
            Plot0.Set(EMA(BarsArray[0],10)[0] );
            }
            }
            But if I delete this "|| CurrentBars[1] < BarsRequired" in my code, then the indicator appear.

            Thank's

            Comment


              #7
              Hello neo-13,
              To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

              Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

              I look forward to assisting you further.

              *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                Originally posted by neo-13 View Post
                Thank's for your answer,
                sorry but I'm french and I don't understand very well english.
                I wrote your code but it don't work:
                protected override void OnBarUpdate()
                {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
                if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
                return;
                Plot0.Set(EMA(BarsArray[0],10)[0] );
                }
                There is no compil error but I don't have indic on my graph.

                The complet code:
                public class MyCompareSerie : Indicator
                {
                #region Variables
                // Wizard generated variables
                private int lenght = 20; // Default setting for Lenght
                // User defined variables (add any user defined variables below)
                #endregion

                /// <summary>
                /// This method is used to configure the indicator and is called once before any bar data is loaded.
                /// </summary>
                protected override void Initialize()
                {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                Add("$EURAUD",PeriodType.Minute, 5);
                //Add("$AUDUSD",PeriodType.Minute, 5);
                Overlay = false;
                }

                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
                if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
                return;
                Plot0.Set(EMA(BarsArray[0],10)[0] );
                }
                }
                But if I delete this "|| CurrentBars[1] < BarsRequired" in my code, then the indicator appear.

                Thank's
                How many bars of data do you have loaded on the chart?

                Comment


                  #9
                  Good morning and thank's for your help,
                  the problem come from my data origin, by default it's last and I have downloaded bid.
                  My error:
                  Add("$EURAUD",PeriodType.Minute, 5);
                  the solution
                  Add("$EURAUD",PeriodType.Minute, 5,MarketDataType.Bid);
                  The NT support give me the solution,

                  so thank's a lot for your help and time.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by owenwong, Today, 06:34 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post owenwong  
                  Started by REI140205, Today, 06:17 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post REI140205  
                  Started by Gathem, Today, 06:06 PM
                  1 response
                  15 views
                  0 likes
                  Last Post Gathem
                  by Gathem
                   
                  Started by tg1886, Today, 04:09 PM
                  3 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_ShawnB  
                  Started by mythue, Today, 03:48 PM
                  2 responses
                  14 views
                  0 likes
                  Last Post mythue
                  by mythue
                   
                  Working...
                  X