Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Migration Issue

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

    Indicator Migration Issue

    Hello

    It took me quite some time but I managed to migrate my complete trading setup (including all custom indicators and strategies) from NT 6.5 to NT 7.

    The only indicator that doesn't work is the following: (NT Log says: Failed to call method "Initialize" for indicator MASlope: "BarsInProgress" property can not be accessed from within "Initialize" method.

    Could someone please point me in the right direction, thanks a lot.

    #region Using declarations
    using System;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.ComponentModel;
    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("Enter the description of your new custom indicator here")]
    public class MASlope : Indicator
    {
    #region Variables
    private int numPeriods = 50;
    private SMA smaperiod;
    private int period = 200;
    #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.Black, "Short Term Slope"));
    Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "ZERO"));
    Add(new Line(Color.FromKnownColor(KnownColor.Red), 10, "PLUS10")); // References +10,-10, ZERO
    Add(new Line(Color.FromKnownColor(KnownColor.Red), -10, "MINUS10"));
    PriceTypeSupported = true;
    smaperiod = SMA(period);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    double slope = Math.Atan(Slope(smaperiod, numPeriods,0)) * 180/Math.PI;

    Short.Set(slope);
    }



    #region Properties
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Short
    {
    get { return Values[0]; }
    }
    [Description("Number of Periods to Gather Slope Across")]
    [Category("Parameters")]
    [Gui.Design.DisplayNameAttribute("# of periods")]
    public int NumPeriods
    {
    get { return numPeriods; }
    set { numPeriods = Math.Max(1, value); }
    }

    [Description("The SMA to derive the slope from")]
    [Category("Parameters")]
    public int Period
    {
    get { return period; }
    set { period = Math.Max(1, value); }
    }


    #endregion
    }
    }

    #2
    I would suggest assigned the 'smaperiod' in the OnBarUpdate(), then please retry.

    Comment


      #3
      perfect, thanks a lot for your support.

      Regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      600 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      346 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
      558 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X