Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with using multi-timeframe indicator in Market Analyzer

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

    Problem with using multi-timeframe indicator in Market Analyzer

    Hi,

    I have daily data for SP500 stocks, but not minute or tick data.

    I wrote a simple multi-timeframe indicator that compare weekly and daily volume to their previous bar.

    The code is here:

    PHP Code:
    namespace NinjaTrader.Indicator
    {
        [Description("Enter the description of your new custom indicator here")]
        public class aatest : Indicator
        {
            protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Dot, "Plot0"));
                CalculateOnBarClose    = true;
                Overlay                = false;
                 Add(PeriodType.Day, 1);
            }
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0 )
                 return;        
                if(BarsInProgress==0)
                  {    if(Volume[0]>Volume[1]&&Volumes[1][0]>Volumes[1][1])
                    {DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + -5 * TickSize, Color.Blue);
                      base.Values[0].Set(1);    }
                      if(Volume[0]<Volume[1]&&Volumes[1][0]<Volumes[1][1])
                    {DrawArrowDown("My up arrow1" + CurrentBar, false, 0, High[0] + 5 * TickSize, Color.Yellow);
                     base.Values[0].Set(-1);}
                 }
            }
            #region Properties
            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries Plot0
            {
                get { return Values[0]; }
            }
            #endregion
        }
    } 
    
    It works on weekly chart of any individual stocks, but now I want to scan the whole list of SP500 stocks and find stocks that has this indicator value equal to 1 or -1, so I opened new Market Analyzer, added column-->indicator-->aatest(the name of this indicator), and in the dataseries box I set the type to week.

    Then I loaded the list of SP500 stock into the Market Analyzer, and in the "aatest" indicator column it all show "#check log#" message, and in the log it says:

    " Failed to call 'OnBarUpdate' method for market analyzer column "aatest": index out of range exception"


    Could you tell me what's the cause of this problem?

    Thanks.

    #2
    kw123 - is this a NinjaTrader 6.5 or 7 issue? If 7, is this on the latest 7.0.0.6 beta?

    Thanks

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      kw123 - is this a NinjaTrader 6.5 or 7 issue? If 7, is this on the latest 7.0.0.6 beta?

      Thanks
      Hi Bertrand,

      Yes, it's on the latest 7.0.0.6 beta.

      Comment


        #4
        Thanks kw123, will check into.

        Comment


          #5
          Works for me after adding a high enough CurrentBars check (satisfying also the added daily series) at the OnBarUpdate() start -

          if (CurrentBar < 900) return;

          Comment


            #6
            Same problem

            Hi Bertrandt

            I have the same problem. Same log entry. Also on NT 7.0.0.6 beta.

            I have added enough bars of weekly data in the market analyzer (# of bars to look back = 200) and I have also added enough data to both BarsInProgress:

            for Weekly Updates
            if (BarsInProgress == 0 && CurrentBar > 100) {...

            for Daily Updates
            if (BarsInProgress == 1 && CurrentBar > 1000)

            I also came across several other request for NinjaTrader providing a sample MultiTimeFrameIndicator for testing purposes. Could you just please post a multitimeframe indicator (weekly, daily) which shows i.e. the crossover of a 3 week SMA and a 10 day SMA.

            In any case, it is just not working by adding enough bars. Also, the aatest indicator is not working for me either.

            Regards
            wtmnn

            Comment


              #7
              Thanks for the suggestion wtmnn - this in on our list of sample to post for NT7, documentation and updated reference samples are work in progess at this point in time.

              Which exact code were you using so I can check into? The exact one provided in the first post?

              Do you get the same error thrown to the log or a different one?

              Thanks

              Comment


                #8
                Hi Bertrand,

                I am sorry for the much delayed reply.

                I also tried the code as you've suggested and it's still not working with my aatest code, I have enough bars as well (over 1000).

                Thanks.

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  Works for me after adding a high enough CurrentBars check (satisfying also the added daily series) at the OnBarUpdate() start -

                  if (CurrentBar < 900) return;
                  Why should he have to check for a value of 900?

                  For the following statement:

                  if(Volume[0]>Volume[1]&&Volumes[1][0]>Volumes[1][1])

                  ...doing the following validity checking first:

                  if (CurrentBar < 1) return;

                  ...should prevent the "index out of range exception".

                  Also, for this case, no checking for BarsInProgress should be required, since for both of the input dataseries we just need to ensure that we can access 1 bar in the past in addition to the current bar.

                  Ignoring everything up to 1000 bars may prevent anything from ever showing (if there's not enough data loaded.)

                  Comment


                    #10
                    Same story index out of bounds

                    Hello,

                    Decided to post just to get email notification from this post, same problem.
                    Looks like MTF for NT7 is not well formed yet.

                    Comment


                      #11
                      KBJ's analysis is accurate. Thank you for the response.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      599 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      344 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      558 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      557 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X