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

Help! TRIN/ Arms indicator wont work..

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

    Help! TRIN/ Arms indicator wont work..

    Hi,
    I came across this indicator at http://www.valtinho.com/post/Arms-In...atrader-7.aspx, and i canīt get i to work. anyone care to have a look att the code to see if itīs faulty or something? My feed suports TRIN index so it isnīt that.

    thanks
    /J
    Attached Files

    #2
    Originally posted by Johan_h View Post
    Hi,
    I came across this indicator at http://www.valtinho.com/post/Arms-In...atrader-7.aspx, and i canīt get i to work. anyone care to have a look att the code to see if itīs faulty or something? My feed suports TRIN index so it isnīt that.

    thanks
    /J
    Who is your data provider , and do you have all these symbols mapped correctly?


    Add("^ADV",PeriodType.Day,1); //1
    Add("^DECL",PeriodType.Day,1); //2
    Add("^UVOL",PeriodType.Day,1); //3
    Add("^DVOL",PeriodType.Day,1); //4

    Comment


      #3
      I have Kinetick as data provider so all of them is supported, but how do i know if they are mapped correctly? I can load them in a chart if that means something?
      Last edited by Johan_h; 10-13-2012, 09:32 AM.

      Comment


        #4
        Originally posted by Johan_h View Post
        I have Kinetick as data provider so all of them is supported, but how do i know if they are mapped correctly?

        Control Center->tools-> instrument manager

        They should be on the left in your instrument list.

        Verify or Add if needed -> search on each one
        then EDIT, misc, Kinetick should have "IINA.Z" for ADV.

        If not in your instrument list, use the LEFT arrow to move to there.

        If everything checks out, and still doesn't work, bring up the output window.

        Tools->Output window, and tell us about any errors there.

        Comment


          #5
          i get this from output ---> Error on calling 'OnBarUpdate' method for indicator 'ArmsIndex' on bar 21: Index was outside the bounds of the array.

          the mapping seems to be ok.

          Comment


            #6
            Originally posted by Johan_h View Post
            i get this from output ---> Error on calling 'OnBarUpdate' method for indicator 'ArmsIndex' on bar 21: Index was outside the bounds of the array.

            the mapping seems to be ok.

            Is this a daily chart?

            How many days of data do you have loaded on your chart? Can you try increasing that #?

            Are you trying to view this in Market Replay or a live connection in SIM?

            You might need to put the line

            Code:
             
            if (CurrentBar < 30) return;
            or some # other than 30 and probably higher. Maybe 6 might work though.





            Comment


              #7
              i increased the number of days from 365 to 600 and still gets the same problem.
              if i use --> if (CurrentBar < 30) return; the error comes at 30 instead of 21 and itīs the same with 6.
              im in sim mode real time.
              itīs a daily chart.
              Last edited by Johan_h; 10-13-2012, 11:11 AM.

              Comment


                #8
                when I changed to


                Code:
                 
                if(CurrentBar >= BarsRequired)
                return;
                it doesnīt say anything in the output but there is still something wrong because itīs not jumping forward to the next step.

                Code:
                 
                switch(BarsInProgress) 
                { 
                
                case 0:
                adv = 0;
                decl = 0; 
                uvol = 0;
                dvol = 0;
                break;
                Last edited by Johan_h; 10-13-2012, 01:38 PM.

                Comment


                  #9
                  Originally posted by sledge View Post
                  Is this a daily chart?

                  How many days of data do you have loaded on your chart? Can you try increasing that #?

                  Are you trying to view this in Market Replay or a live connection in SIM?

                  You might need to put the line

                  Code:
                   
                  if (CurrentBar < 30) return;
                  or some # other than 30 and probably higher. Maybe 6 might work though.





                  http://www.ninjatrader.com/support/f...x+bounds+array
                  What is the timeframe of the chart on which you are placing the indicator?

                  Comment


                    #10
                    Itīs a daily chart with 365 days displayed

                    Comment


                      #11
                      Originally posted by Johan_h View Post
                      Itīs a daily chart with 365 days displayed
                      Nothing jumps out as being out of the bounds of any array. You are going to have to put in some Print() statements to see exactly where it is bombing out.

                      Comment


                        #12
                        Originally posted by koganam View Post
                        Nothing jumps out as being out of the bounds of any array. You are going to have to put in some Print() statements to see exactly where it is bombing out.
                        i have done that:

                        Code:
                         
                        protected override void OnBarUpdate()
                        {
                        Print("before1");
                        if (CurrentBar >= BarsRequired)
                        Print("after1");
                        return;
                        and i get 100 "before1" prints before i get alot of alternating "before1" and "after1" prints.

                        Comment


                          #13
                          Originally posted by Johan_h View Post
                          i have done that:

                          Code:
                           
                          protected override void OnBarUpdate()
                          {
                          Print("before1");
                          if (CurrentBar >= BarsRequired)
                          Print("after1");
                          return;
                          and i get 100 "before1" prints before i get alot of alternating "before1" and "after1" prints.
                          That will be about right as you will get 5 tick events per tick (one for each barSeries), and the default value for BarsRequired is 20.

                          You are going to need Print() statements in the branches of the switch statement to see if they are getting executed.

                          If not, then you probably have to explicitly check for the barSeries' validity, even though given that all barSeries are 1-day, one would expect that that should not be necessary.

                          Here is the code that I use in multi-timeframe scripts:


                          Code:
                          private int _intEscapeBars = 3; //how many bars before we start  processing, usually 1, made 3 here for illustration
                          private bool allBarSeriesValid = false;
                          Code:
                           
                                  protected override void OnBarUpdate()
                                  {
                                     if (!allBarSeriesValid)
                                        {
                                           for (int index = 0; index < BarsArray.Length; index++) 
                                            {
                                                if (CurrentBars[index] < this._intEscapeBars) return;
                                                allBarSeriesValid = true;
                                            } 
                                        }
                                      // the rest goes here ... 
                                  }
                          When written this way, you do not have to even think about how many Bars objects you add to the indicator: the escapes will be automatically handled, dynamically, for the correct number of Bars objects.

                          Comment


                            #14
                            Originally posted by koganam View Post
                            That will be about right as you will get 5 tick events per tick (one for each barSeries), and the default value for BarsRequired is 20.

                            You are going to need Print() statements in the branches of the switch statement to see if they are getting executed.

                            If not, then you probably have to explicitly check for the barSeries' validity, even though given that all barSeries are 1-day, one would expect that that should not be necessary.

                            Here is the code that I use in multi-timeframe scripts:


                            Code:
                            private int _intEscapeBars = 3; //how many bars before we start  processing, usually 1, made 3 here for illustration
                            private bool allBarSeriesValid = false;
                            Code:
                             
                                    protected override void OnBarUpdate()
                                    {
                                       if (!allBarSeriesValid)
                                          {
                                             for (int index = 0; index < BarsArray.Length; index++) 
                                              {
                                                  if (CurrentBars[index] < this._intEscapeBars) return;
                                                  allBarSeriesValid = true;
                                              } 
                                          }
                                        // the rest goes here ... 
                                    }
                            When written this way, you do not have to even think about how many Bars objects you add to the indicator: the escapes will be automatically handled, dynamically, for the correct number of Bars objects.
                            Okey, that made a lot of difference, thanks! i simplifyed the code using ^TRIN / ^TRINQ and now it runs through the whole code, there is one little problem thou, i canīt get a Closes[1][0] value from the ^TRIN or ^TRINQ object. any ideas? iīve attached the code. i used Print(trinValue); but it just put zeros in the output window..
                            Attached Files
                            Last edited by Johan_h; 10-14-2012, 02:56 PM.

                            Comment


                              #15
                              Originally posted by Johan_h View Post
                              Okey, that made a lot of difference, thanks! i simplifyed the code using ^TRIN / ^TRINQ and now it runs through the whole code, there is one little problem thou, i canīt get a Closes[1][0] value from the ^TRIN or ^TRINQ object. any ideas? iīve attached the code. i used Print(trinValue); but it just put zeros in the output window..
                              Try moving these lines to declare the variables as class variables.
                              Code:
                                         double tr=0;
                                          double trq=0;
                              It looks to me as if they are being unconditionally reset on every tick, no matter which barSeries generated it.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by GLFX005, Today, 03:23 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by nandhumca, Yesterday, 03:41 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by The_Sec, Yesterday, 03:37 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by vecnopus, Today, 06:15 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post vecnopus  
                              Working...
                              X