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

Custom Indicator not working with ALL instruments...

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

    Custom Indicator not working with ALL instruments...

    I have a custom indicator that I created using ^adv and ^dec. It will work with SPY and IWM but not with VWO, MDY and a custom created SPX.CO as a stock for data going back to 1965. Any general ideas on why this may be?

    #2
    Hello dunwoodyjr,

    Are you able to load up a Chart with those instruments by themselves?

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Yes, I am. For a trial, I pulled up a daily chart going the default 365 bars. Then, I added the indicator. On some, it worked and other, it shows the scale on the right side properly, but no data...

      Comment


        #4
        Hello dunwoodyjr,

        Could you post a screenshot of your charts? You may take a screenshot by pressing Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image.

        For detailed instructions please visit the following link

        How to take a screenshot on your smartphone, tablet, notebook or desktop computer


        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Attached Charts. SPY working. Which to SPYX...not working.
          Attached Files

          Comment


            #6
            Hello dunwoodyjr,

            Thanks for the screenshots.

            Do you see any errors inside of your Log tab when you bring up the SPYX?

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              Yes, it does. Sorry. Did not check that first. Please explain what this means...

              Error on calling 'OnBarUpdate' method for indicator 'Daily Impulse' on bar 0. You are accessing an index with a value that is invalid since its out of range.

              Thank you

              Comment


                #8
                GOT IT...

                I reviewed the site and found I needed to add something like this after

                protected override void OnBarUpdate()

                (CurrentBar < 10) return;

                Works now...

                BUT, I also had my securities set to different Session Templates. Changing them to US Equities from 24/7 finally sync'd everything...
                Last edited by dunwoodyjr; 09-06-2013, 04:55 PM.

                Comment


                  #9
                  Same Problem occuring...Mismatched Indicator

                  Please see the attached charts. Open is a Chart, one a chart in Strategy Analyzer. Both contain an custom indicator named Daily Impulse. Problem is the indicator is calculating differently under each. Do you know why/what would cause this? Thanks...
                  Attached Files

                  Comment


                    #10
                    Hello dunwoodyjr,

                    Every setting is going to have to match in order to have the Strategy Analyzer window match your chart.

                    Can you verify that all of your settings match for the Data Series? Note that typically the days to load or setting the From and To date on both the Strategy Analyzer and the Chart is the main reason why they are different.

                    Let me know if this helps.
                    JCNinjaTrader Customer Service

                    Comment


                      #11
                      Every setting matches EXCEPT for number of days, BUT why should that matter for an indicator that is only using a 10 day SMA? If one chart it 3650 days and the the Strategy Analyzer is 56 years, Sept 10, 2013 should equal the same thing, since I am only using the past 10 days, right?

                      Comment


                        #12
                        Hello dunwoodyjr,

                        It can change the values because NinjaTrader will start to load all Indicators and Strategies from the beginning of the data to so if it has a different starting point it can change the values of the script.

                        If you change the dates to match do you see your indicator values matching as well?

                        Happy to be of further assistance.
                        JCNinjaTrader Customer Service

                        Comment


                          #13
                          Sorry to dwell but it is VERY important. If I have custom indicators that only use the last 10 bars to determine the value, it should not make a difference when I start the data. If I am doing Strategy Analyzer, I need the REAL 10 day value, the same one that if I computed my hand, to determine causations. If NJT is calculating a different value each time I change the date, then the indicator is worthless, since it is not the actual value. See what I am saying. Again, once 10 bars pass, the indicator should be calculated and the value should be the same REGARDLESS of what starting date I use. There are only 10 bars needed to compute.

                          I have used NJT on and off to play with for years, but only recently have I gotten to a point where I am ready to go with algo trading. Since I have been using NJT for a long time, obviously, my inclination is to buy it. BUT, this seems to be a serious flaw, if what you are telling me is true. It means that ALL indicators are somewhat arbitrarily calculated based on start dates. That can't be right. Too many people use NJT and this would have had to been addressed. So, again, what difference to a 10 bar indicator should it mean if I start date it 365 bars ago or 3650 bars ago and WHY am I getting different results? Thank you for your patience on this...

                          Comment


                            #14
                            Hello dunwoodyjr,

                            NinjaTrader will always start loading NinjaScript files based on the data that it is being loaded into it.

                            So if you want your calculations to only be based on the last 10 days worth of data you will need to make sure that you program your indicator accordingly.

                            Could you post an example or a snippet of how you are calculating your indicator value? If you do not wish to disclose this on the forum you may send an email to us for privacy.

                            Happy to be of further assistance.
                            JCNinjaTrader Customer Service

                            Comment


                              #15
                              Here it is. It is a simple Advance Decline 10 SMA Buy/Sell:

                              #region Using declarations
                              using System;
                              using System.ComponentModel;
                              using System.Diagnostics;
                              using System.Drawing;
                              using System.Drawing.Drawing2D;
                              using System.Xml.Serialization;
                              using NinjaTrader.Cbi;
                              using NinjaTrader.Data;
                              using NinjaTrader.Gui.Chart;
                              #endregion

                              // This namespace holds all indicators and is required. Do not change it.
                              namespace NinjaTrader.Indicator
                              {
                              /// <summary>
                              /// Enter the description of your new custom indicator here
                              /// </summary>
                              [Description("Buy when 10SMA is above .615 and sell at break below .49")]
                              public class DailyImpulse : Indicator
                              {
                              #region Variables
                              // Wizard generated variables
                              private int sMAInput = 10; // Default setting for MyInput0
                              // 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.RoyalBlue), PlotStyle.Line, "Signal"));
                              Add(new Line(Color.FromKnownColor(KnownColor.DarkRed), 0.48, "BuySellLine"));
                              Overlay = false;

                              Add ("^ADV", PeriodType.Day, 1);
                              Add ("^DECL", PeriodType.Day, 1);



                              aDVDECSeries = new DataSeries(this);

                              }

                              /// <summary>
                              /// Called on each bar update event (incoming tick)
                              /// </summary>
                              protected override void OnBarUpdate()
                              {


                              double ADV1 = BarsArray[1][0];
                              double DEC1 = BarsArray[2][0];
                              double ADavg = (ADV1/(ADV1 + DEC1));

                              aDVDECSeries.Set(ADavg);


                              Signal.Set(SMA(aDVDECSeries, SMAInput) [0]);

                              }

                              #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 Signal
                              {
                              get { return Values[0]; }
                              }

                              [Description("")]
                              [GridCategory("Parameters")]
                              public int SMAInput
                              {
                              get { return sMAInput; }
                              set { sMAInput = Math.Max(1, value); }
                              }

                              private DataSeries aDVDECSeries;

                              #endregion
                              }
                              }


                              This morning I ran a Strategy Analyzer for SPY. 1st one from 1/1/1995 and 2nd from 1/1/2005. 1st one ended with yesterday value at .511, while the 2nd one ended with a value of .555.

                              **Would the $199 training class cover programming issues like this? If so, I simply sign up for a future class...**

                              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
                              8 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