Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator not showing up in the indicator list

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

    Indicator not showing up in the indicator list

    Hi I modify this indicator and is not showing up in indicator list, I see it in the script ​editor
    I only add this line (AddLine(Brushes.White, 50, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer) the one in red




    //
    // Copyright (C) 2023, NinjaTrader LLC <www.ninjatrader.com>.
    // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
    //MG Stochastic
    //
    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    // This namespace holds indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    /// <summary>
    /// The Stochastic Oscillator is made up of two lines that oscillate between
    /// a vertical scale of 0 to 100. The %K is the main line and it is drawn as
    /// a solid line. The second is the %D line and is a moving average of %K.
    /// The %D line is drawn as a dotted line. Use as a buy/sell signal generator,
    /// buying when fast moves above slow and selling when fast moves below slow.
    /// </summary>
    public class MGStochastick : Indicator
    {
    private Series<double> den;
    private Series<double> fastK;
    private MIN min;
    private MAX max;
    private Series<double> nom;
    private SMA smaFastK;
    private SMA smaK;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionStochastics;
    Name = "MGStochastick";
    IsSuspendedWhileInactive = true;
    PeriodD = 5;
    PeriodK = 21;
    Smooth = 7;

    AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.StochasticsD);
    AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.StochasticsK);

    AddLine(Brushes.DarkCyan, 20, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer);
    AddLine(Brushes.White, 50, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer);
    AddLine(Brushes.DarkCyan, 80, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUp per);
    }
    else if (State == State.DataLoaded)
    {
    den = new Series<double>(this);
    nom = new Series<double>(this);
    fastK = new Series<double>(this);
    min = MIN(Low, PeriodK);
    max = MAX(High, PeriodK);
    smaFastK = SMA(fastK, Smooth);
    smaK = SMA(K, PeriodD);
    }
    }

    protected override void OnBarUpdate()
    {
    double min0 = min[0];
    nom[0] = Close[0] - min0;
    den[0] = max[0] - min0;

    if (den[0].ApproxCompare(0) == 0)
    fastK[0] = CurrentBar == 0 ? 50 : fastK[1];
    else
    fastK[0] = Math.Min(100, Math.Max(0, 100 * nom[0] / den[0]));

    // Slow %K == Fast %D
    K[0] = smaFastK[0];
    D[0] = smaK[0];
    }

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

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

    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "PeriodD", GroupName = "NinjaScriptParameters", Order = 0)]
    public int PeriodD
    { get; set; }

    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "PeriodK", GroupName = "NinjaScriptParameters", Order = 1)]
    public int PeriodK
    { get; set; }

    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Smooth", GroupName = "NinjaScriptParameters", Order = 2)]
    public int Smooth
    { get; set; }
    #endregion
    }
    }​




    Attached Files
    Last edited by mgco4you; 09-04-2023, 12:41 PM.

    #2
    Hello mgco4you,

    The image you attached did not upload, please edit your post or reply with the image.

    If you are adding a new line you need to make a unique name for it, its possible you are getting an error. Use the following instead:

    AddLine(Brushes.White, 50, "50line");

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello mgco4you,

      The image you attached did not upload, please edit your post or reply with the image.

      If you are adding a new line you need to make a unique name for it, its possible you are getting an error. Use the following instead:

      AddLine(Brushes.White, 50, "50line");
      -----------------------------------

      Isint this thesame?

      AddLine(Brushes.DarkCyan, 20, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer);
      AddLine(Brushes.White, 50, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer); <======Add it this line what is wrong with it
      AddLine(Brushes.DarkCyan, 80, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUp per);​

      Comment


        #4
        Hello mgco4you,

        You never need to use NinjaTrader.Custom.Resource. strings in code that you add, those are the platforms regionalization strings. You are adding two lines with the exact same name by repeating that same resource name. The code I provided would be how you make a custom new line .

        AddLine(Brushes.White, 50, "50line");

        Comment


          #5
          I did the change but dint like it


          Attached Files

          Comment


            #6
            still no show up in the list


            AddLine(Brushes.DarkCyan, 20, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer);
            AddLine(Brushes.DarkCyan, 80, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUp per);
            AddLine(Brushes.White, 50, "50line");
            }​

            Comment


              #7
              Hello mgco4you,

              Are you removing the indicator from the chart and re adding it after making that change?

              Comment


                #8
                no let me try that thanks

                Dint work
                Last edited by mgco4you; 09-04-2023, 01:27 PM. Reason: ​​​​​​​Dint work ADDit

                Comment


                  #9
                  The indicator do not show in the list, it was saved with a new name MGStochastics, removing the one on the charts 100s of them "Stochastics" and adding what the one that dont show up in the indicator list?

                  Comment


                    #10
                    Hello mgco4you,

                    Check the control center log tab for errors. If it has errors it wont show up in the list.

                    Comment


                      #11
                      I dint have any error on the first one, I don't know all I want is to add a 50 line if there is a way copy the script above make the change and I will make a new indicator.... this back and forth is time consuming. thanks in advance, and I wont bother you no more.............

                      Comment


                        #12
                        Hello mgco4you,

                        Sometime some replies are required to find the problem. Did you see an error? if so please post it.

                        Are you compiling the script by pressing F5 or the compile button?

                        If you add a new line it should show up, AddLine is a single method that adds a static line to the chart at the value you specify, The only requirement is a unique name.



                        Comment


                          #13
                          you ask "Are you compiling the script by pressing F5 or the compile button?" no just the save function now I did and there is to error

                          Attached Files

                          Comment


                            #14
                            Hello mgco4you,

                            To see changes you need to compile when you edit a script.

                            If you are getting an error we would need to be able to see the full error. Please left click on the error line and press Control + C. Then paste the error into your reply.

                            Comment


                              #15
                              Ok got it to work
                              But now I have to redo all my charts

                              thank you

                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

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