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 not working with all instruments

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

    Indicator not working with all instruments

    I have built an indicator based on Wordens T2107. I first create a stock instrument "T2107', then imported the Price data. The symbol will work when pulled up as a Chart.

    I then add the indicator to the T2017 chart and it works fine, giving me a running value between 0.0 and 1.0.

    However, when I try to add the indicator to, say, the SPY chart, it indicator window is blank.

    I have noticed this before on some other custom indicators I have constructed. Some will work with other instruments, other with just it's "root"

    Am I missing a code line that allows it to be referenced by ALL instruments perhaps?

    [Description("% Stocks Above 200 Day SMA")]
    public class T2107indicator : Indicator
    {
    #region Variables
    // Wizard generated variables
    private double wordenInput1 = 1; // Default setting for WordenInput1
    private int currentBars1 = -1;
    // 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.SkyBlue), PlotStyle.Line, "Plot0"));
    Overlay = false;

    Add ("T2107", PeriodType.Day, 1);

    t2107Series = new DataSeries(this);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if(CurrentBars[1] > currentBars1);

    double AT2107 = BarsArray[1][0];

    t2107Series.Set(AT2107);

    Plot0.Set((t2107Series) [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 Plot0
    {
    get { return Values[0]; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public double WordenInput1
    {
    get { return wordenInput1; }
    set { wordenInput1 = Math.Max(1, value); }
    }

    private DataSeries t2107Series; // Declare a DataSeries variable

    #endregion

    #2
    Originally posted by dunwoodyjr View Post
    I have built an indicator based on Wordens T2107. I first create a stock instrument "T2107', then imported the Price data. The symbol will work when pulled up as a Chart.

    I then add the indicator to the T2017 chart and it works fine, giving me a running value between 0.0 and 1.0.

    However, when I try to add the indicator to, say, the SPY chart, it indicator window is blank.

    I have noticed this before on some other custom indicators I have constructed. Some will work with other instruments, other with just it's "root"

    Am I missing a code line that allows it to be referenced by ALL instruments perhaps?

    [Description("% Stocks Above 200 Day SMA")]
    public class T2107indicator : Indicator
    {
    #region Variables
    // Wizard generated variables
    private double wordenInput1 = 1; // Default setting for WordenInput1
    private int currentBars1 = -1;
    // 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.SkyBlue), PlotStyle.Line, "Plot0"));
    Overlay = false;

    Add ("T2107", PeriodType.Day, 1);

    t2107Series = new DataSeries(this);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if(CurrentBars[1] > currentBars1);

    double AT2107 = BarsArray[1][0];

    t2107Series.Set(AT2107);

    Plot0.Set((t2107Series) [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 Plot0
    {
    get { return Values[0]; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public double WordenInput1
    {
    get { return wordenInput1; }
    set { wordenInput1 = Math.Max(1, value); }
    }

    private DataSeries t2107Series; // Declare a DataSeries variable

    #endregion
    First of all your filter is a null statement because you have terminated it with a semi-colon. Due to that, all your statements will be triggered on all bars.

    You should have an error on your log about the invalidity of the Plot because of a lack of bars. What is the error in your log?

    Comment


      #3
      Hello dunwoodyjr,

      Thank you for your post.

      koganam is correct, there should be an error. Please provide the error as listed in your Log when you attempt to open the Indicators window and select the indicator.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by techgetgame, Today, 11:42 PM
      0 responses
      7 views
      0 likes
      Last Post techgetgame  
      Started by sephichapdson, Today, 11:36 PM
      0 responses
      1 view
      0 likes
      Last Post sephichapdson  
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,612 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      9 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      19 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Working...
      X