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

Indicator no longer working

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

    Indicator no longer working

    I have an indicator that measures bar duration (in seconds only,not minutes and seconds)
    It stopped working today. Any ideas?
    It still compiles I just get an empty panel.

    Code:
    protected override void OnBarUpdate()
    {
    		
    if(CurrentBar < 3)
    return;
    		
    bartimespan = Bars.GetTime(CurrentBar) - Bars.GetTime(CurrentBar -1); 
    
    n2 = Convert.ToInt32(bartimespan.Seconds);
    n3 = Convert.ToInt32(bartimespan.Minutes*60);
    					
    spanseries.Set(n2+n3);
    		
    RangeTimeEMA.Set(EMA(spanseries,21)[0]);
    string avg = String.Format("{0:N0}",spanseries[1]);
    Plot0.Set(Math.Min((spanseries)[0],600));
    DrawTextFixed("BottomRight", "Current\n" +spanseries[0]+"\nPrior \n"+spanseries[3]+"," + spanseries[2]+"," + spanseries[1],
    		TextPosition.BottomRight,Color.White,ChartControl.Font,Color.Black,Color.Blue,10);
    }

    #2
    Hi Mindset,

    At a glance I don't see anything obvious, however, I would certainly check the Log tab for any errors.

    From there, try using Print() statements to figure out which parts/calculations are going awry.

    More info at - http://www.ninjatrader.com/support/f...ead.php?t=3418
    TimNinjaTrader Customer Service

    Comment


      #3
      Doh!

      The error seems to be in the line

      RangeTimeEMA.Set((EMA(spanseries,21)[0]

      I amended another line to
      if(CurrentBar < 25 )
      return;

      I can see that spanseries doesn't have 21 nos to average, how do I get around that?

      Comment


        #4
        Hi Mindset,

        Try moving your CurrentBar check to the line just before...

        RangeTimeEMA.Set(EMA(spanseries,21)[0]);

        That way the values are calculated before you try to access them 21 bars back.
        TimNinjaTrader Customer Service

        Comment


          #5
          Current Bar

          CurrentBar check is first line of OnBarUpdate.
          if I comment out the rangetimeema line it works (minus the ema line of course).
          If the line is in it compiles but no output.

          Comment


            #6
            Hi Mindset,

            Have you tried adding the second CurrentBar check?

            Code:
            protected override void OnBarUpdate()
            {
            		
            if(CurrentBar < 3)
            return;
            		
            bartimespan = Bars.GetTime(CurrentBar) - Bars.GetTime(CurrentBar -1); 
            
            n2 = Convert.ToInt32(bartimespan.Seconds);
            n3 = Convert.ToInt32(bartimespan.Minutes*60);
            					
            spanseries.Set(n2+n3);
            
            if(CurrentBar < 25 )
            return;		
            
            RangeTimeEMA.Set(EMA(spanseries,21)[0]);
            string avg = String.Format("{0:N0}",spanseries[1]);
            Plot0.Set(Math.Min((spanseries)[0],600));
            DrawTextFixed("BottomRight", "Current\n" +spanseries[0]+"\nPrior \n"+spanseries[3]+"," + spanseries[2]+"," + spanseries[1],
            		TextPosition.BottomRight,Color.White,ChartControl.Font,Color.Black,Color.Blue,10);
            }
            TimNinjaTrader Customer Service

            Comment


              #7
              Tried that

              Doesn't work.
              Let me think on this - I am sure it is simple to resolve.

              Comment


                #8
                Hi Mindset,

                To clarify, is the text not showing at all? One of the plots?

                Are you still getting errors in the Log? What errors?
                TimNinjaTrader Customer Service

                Comment


                  #9
                  Error

                  I am getting an index outside bounds of array error. And neither plot shows.
                  If I comment out the rangetimeema I get the first plot but not the second.

                  Comment


                    #10
                    MindSet, are you working on 65 or 7 beta with this indicator? Would you mind attaching the full cs / zip for us to test? On NT7 the dataseries handling slighly changed and all points would need a setting of value otherwise you could run into those exceptions like you've seen. Thanks.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Zip

                      Hi Bertrand

                      7b15.

                      I have another issue in that I can't export from NT7 currently ( related issue?)

                      so here is a cs version that you can test.
                      Attached Files

                      Comment


                        #12
                        Hi Mindset,

                        Looking at your code, it seems you do not have a plot for "RangeTimeEMA"

                        Adding...

                        Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "RangeTimeEMA"));

                        to Initialize() solved this on my end.

                        As for exporting, what issue are you experiencing?
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          lol

                          That's hilarious - well done,Tim. A real Homer moment. I am fascinated that it worked for 3 days without that line??
                          The other issue I am dealing with support already - I suspect a reinstall is due.
                          :-(

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by fx.practic, 10-15-2013, 12:53 AM
                          5 responses
                          5,404 views
                          0 likes
                          Last Post Bidder
                          by Bidder
                           
                          Started by Shai Samuel, 07-02-2022, 02:46 PM
                          4 responses
                          95 views
                          0 likes
                          Last Post Bidder
                          by Bidder
                           
                          Started by DJ888, Yesterday, 10:57 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by MacDad, 02-25-2024, 11:48 PM
                          7 responses
                          159 views
                          0 likes
                          Last Post loganjarosz123  
                          Started by Belfortbucks, Yesterday, 09:29 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post Belfortbucks  
                          Working...
                          X