Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indi translation error CS10061

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

    Indi translation error CS10061

    Currently I am having an issue in a simple translation of a NT7 indictor to NT8.

    The NT7 version of the Guppy MACD uses the term "set" to define in OnBarUpdate but NT8 doesn't use this. Ive been researching the problem but decided to come here after not having much luck.


    Click image for larger version

Name:	Capture.PNG
Views:	343
Size:	42.8 KB
ID:	1123555



    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class GuppyMACD : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "GuppyMACD";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = false;
    DrawVerticalGridLines = false;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    Fast = 8;
    Slow = 17;
    Smooth = 9;
    FFast = 7;
    SSlow = 16;
    SSmooth = 8;
    FFFast = 6;
    SSSlow = 15;
    SSSmooth = 7;
    HistoScale = 1;
    AddPlot(Brushes.Orange, "MACD1Main");
    AddPlot(Brushes.MistyRose, "MACD1Avg");
    AddPlot(Brushes.DarkOrange, "MACD2Main");
    AddPlot(Brushes.DodgerBlue, "MACD2Avg");
    AddPlot(Brushes.Red, "MACD3Main");
    AddPlot(Brushes.Chartreuse, "MACD3Avg");
    AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Bar, "HistoUp");
    AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Bar, "HistoDown");
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic hereif( CurrentBar < 1 )


    MACD1Main.Set( MACD( Fast, Slow, Smooth )[ 0 ] );
    MACD1Avg.Set( MACD( Fast, Slow, Smooth ).Avg[ 0 ] );
    MACD2Main.Set( MACD( FFast, SSlow, SSmooth )[ 0 ] );
    MACD2Avg.Set( MACD( FFast, SSlow, SSmooth ).Avg[ 0 ] );
    MACD3Main.Set( MACD( FFFast, SSSlow, SSSmooth )[ 0 ] );
    MACD3Avg.Set( MACD( FFFast, SSSlow, SSSmooth ).Avg[ 0 ] );
    double diff0 = MACD1Main[ 0 ] - MACD1Avg[ 0 ];
    double diff1 = MACD1Main[ 1 ] - MACD1Avg[ 1 ];
    if( diff0 >= diff1 )
    HistoUp.Set( diff0 * HistoScale );
    else
    HistoDown.Set( diff0 * HistoScale );

    }

    #region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Fast", Description="Number of bars for fast EMA", Order=1, GroupName="Parameters")]
    public int Fast
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Slow", Description="Number of bars for slow EMA", Order=2, GroupName="Parameters")]
    public int Slow
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Smooth", Description="Number of bars for smoothing", Order=3, GroupName="Parameters")]
    public int Smooth
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="FFast", Description="Number of bars for fast EMA", Order=4, GroupName="Parameters")]
    public int FFast
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="SSlow", Description="Number of bars for slow EMA", Order=5, GroupName="Parameters")]
    public int SSlow
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="SSmooth", Description="Number of bars for smoothing", Order=6, GroupName="Parameters")]
    public int SSmooth
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="FFFast", Order=7, GroupName="Parameters")]
    public int FFFast
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="SSSlow", Order=8, GroupName="Parameters")]
    public int SSSlow
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="SSSmooth", Order=9, GroupName="Parameters")]
    public int SSSmooth
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, double.MaxValue)]
    [Display(Name="HistoScale", Description="Scale Histogram by factor x", Order=10, GroupName="Parameters")]
    public double HistoScale
    { get; set; }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MACD1Main
    {
    get { return Values[0]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MACD1Avg
    {
    get { return Values[1]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MACD2Main
    {
    get { return Values[2]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MACD2Avg
    {
    get { return Values[3]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MACD3Main
    {
    get { return Values[4]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MACD3Avg
    {
    get { return Values[5]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> HistoUp
    {
    get { return Values[6]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> HistoDown
    {
    get { return Values[7]; }
    }
    #endregion

    #2
    Hello Teebone21,

    Thanks for your post.

    With reference to https://ninjatrader.com/support/help...ng_changes.htm The changes advise, "The DataSeries.Set() method used to assign Data Series or Plot values has been removed and values can now be stored using a single assignment operator:"

    For example NT7 HistoUp.Set( diff0 * HistoScale ); becomes NT8 HistoUp[0] = diff0 * HistoScale;

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello Teebone21,

      Thanks for your post.

      With reference to https://ninjatrader.com/support/help...ng_changes.htm The changes advise, "The DataSeries.Set() method used to assign Data Series or Plot values has been removed and values can now be stored using a single assignment operator:"

      For example NT7 HistoUp.Set( diff0 * HistoScale ); becomes NT8 HistoUp[0] = diff0 * HistoScale;
      Thanks! ive taken on the task of learning how to code i forgot to look at this section instead of google

      Comment


        #4
        Now it wont plot for some odd reason after successful complication.

        namespace NinjaTrader.NinjaScript.Indicators
        {
        public class GuppyMACD : Indicator
        {
        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = @"Enter the description for your new custom Indicator here.";
        Name = "GuppyMACD";
        Calculate = Calculate.OnBarClose;
        IsOverlay = false;
        DisplayInDataBox = true;
        DrawOnPricePanel = true;
        DrawHorizontalGridLines = false;
        DrawVerticalGridLines = false;
        PaintPriceMarkers = true;
        ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
        //Disable this property if your indicator requires custom values that cumulate with each new market data event.
        //See Help Guide for additional information.
        IsSuspendedWhileInactive = true;
        Fast = 8;
        Slow = 17;
        Smooth = 9;
        FFast = 7;
        SSlow = 16;
        SSmooth = 8;
        FFFast = 6;
        SSSlow = 15;
        SSSmooth = 7;
        HistoScale = 1;
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "MACD1Main"); //Plot8
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "MACD1Avg"); //Plot8
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "MACD2Main"); //Plot8
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "MACD2Avg"); //Plot8 "MACD2Avg");
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "MACD3Main"); //Plot8
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "MACD3Avg"); //Plot8
        AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Bar, "HistoUp");
        AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Bar, "HistoDown");
        }
        }
        else if (State == State.Configure)
        {
        }
        }

        protected override void OnBarUpdate()
        {
        //Add your custom indicator logic hereif( CurrentBar < 1 )

        ///cannot use the term "set" in nt8 look at Code Break documentation
        MACD1Main[0] =( MACD( Fast, Slow, Smooth )[ 0 ] );
        MACD1Avg[0]=( MACD( Fast, Slow, Smooth ).Avg[ 0 ] );
        MACD2Main[0]=( MACD( FFast, SSlow, SSmooth )[ 0 ] );
        MACD2Avg[0]=( MACD( FFast, SSlow, SSmooth ).Avg[ 0 ] );
        MACD3Main[0]=( MACD( FFFast, SSSlow, SSSmooth )[ 0 ] );
        MACD3Avg[0]=( MACD( FFFast, SSSlow, SSSmooth ).Avg[ 0 ] );
        double diff0 = MACD1Main[ 0 ] - MACD1Avg[ 0 ];
        double diff1 = MACD1Main[ 1 ] - MACD1Avg[ 1 ];
        if( diff0 >= diff1 )
        HistoUp[0] =( diff0 * HistoScale );
        else
        HistoDown[0] = ( diff0 * HistoScale );

        }

        #region Properties
        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="Fast", Description="Number of bars for fast EMA", Order=1, GroupName="Parameters")]
        public int Fast
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="Slow", Description="Number of bars for slow EMA", Order=2, GroupName="Parameters")]
        public int Slow
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="Smooth", Description="Number of bars for smoothing", Order=3, GroupName="Parameters")]
        public int Smooth
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="FFast", Description="Number of bars for fast EMA", Order=4, GroupName="Parameters")]
        public int FFast
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="SSlow", Description="Number of bars for slow EMA", Order=5, GroupName="Parameters")]
        public int SSlow
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="SSmooth", Description="Number of bars for smoothing", Order=6, GroupName="Parameters")]
        public int SSmooth
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="FFFast", Order=7, GroupName="Parameters")]
        public int FFFast
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="SSSlow", Order=8, GroupName="Parameters")]
        public int SSSlow
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, int.MaxValue)]
        [Display(Name="SSSmooth", Order=9, GroupName="Parameters")]
        public int SSSmooth
        { get; set; }

        [NinjaScriptProperty]
        [Range(1, double.MaxValue)]
        [Display(Name="HistoScale", Description="Scale Histogram by factor x", Order=10, GroupName="Parameters")]
        public double HistoScale
        { get; set; }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MACD1Main
        {
        get { return Values[0]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MACD1Avg
        {
        get { return Values[1]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MACD2Main
        {
        get { return Values[2]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MACD2Avg
        {
        get { return Values[3]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MACD3Main
        {
        get { return Values[4]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MACD3Avg
        {
        get { return Values[5]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> HistoUp
        {
        get { return Values[6]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> HistoDown
        {
        get { return Values[7]; }
        }
        #endregion

        }
        }
        Last edited by Teebone21; 10-20-2020, 08:07 AM.

        Comment


          #5
          Hello Teebone21,

          Thanks for your reply.

          When a script is not working as expected, please check the "Log" tab of the NinjaTrader control center for any run time errors that may have occurred.

          I suspect it relates to bar index error.

          in your code it appears you may have accidentally commented out the current bar check: //Add your custom indicator logic hereif( CurrentBar < 1 )

          It needs to be:

          if( CurrentBar < 1 ) return;

          Comment


            #6
            Originally posted by NinjaTrader_PaulH View Post
            Hello Teebone21,

            Thanks for your reply.

            When a script is not working as expected, please check the "Log" tab of the NinjaTrader control center for any run time errors that may have occurred.

            I suspect it relates to bar index error.

            in your code it appears you may have accidentally commented out the current bar check: //Add your custom indicator logic hereif( CurrentBar < 1 )

            It needs to be:

            if( CurrentBar < 1 ) return;
            Thanks! i have alot to learn lol but i am in it for the long run

            Comment


              #7
              Hello Teebone21,
              You're using if(CurrentBar<1) in comment, correct it & see if it works.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              573 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X