• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
      Patrick H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Simon Investimens, Today, 03:26 AM
      0 responses
      3 views
      0 likes
      Last Post Simon Investimens  
      Started by EnveousColnago, Yesterday, 06:58 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by owreivmatot, Today, 01:38 AM
      0 responses
      1 view
      0 likes
      Last Post owreivmatot  
      Started by lindsayf, Today, 01:13 AM
      0 responses
      6 views
      0 likes
      Last Post lindsayf  
      Started by thgamey, Yesterday, 06:46 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X