Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Color Stochastic/2-line Indicator

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

    Color Stochastic/2-line Indicator

    Hello,

    Does anyone have a Color Stochastic, any colored 2-line indicator, or a tutorial for coloring indicators with more than one line? Color's a huge help for determining "has that indicator really turned?" and I'm going bananas trying to convert the Sample color SMA template. Thanks for your help,

    Cheers,
    Jeremy

    #2
    Check out this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3227

    There is also a similar tutorial here: http://www.ninjatrader-support.com/H...tml?Overview25
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thanks for the tutorials, I've tried to hash the two together & set up my 3 Plot lines for the rising/neutral/falling D-line but the indicator is full of errors.

      In lines like
      "DRisingPlot.Set(1, Stochastics(Period)[1]);"
      I've changed it to
      "DRisingPlot.Set(1, Stochastics(K, D, Smooth)[1]);"
      but this is a guess & I only need the D-line colored.

      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "DRising"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "DNeutral"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DFalling"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "KLine"));
      Add(new Line(Color.FromKnownColor(KnownColor.DarkOrchid), 80, "Eightyline"));
      Add(new Line(Color.FromKnownColor(KnownColor.DarkOrchid), 20, "Twentyline"));
      CalculateOnBarClose = true;
      Overlay = false;
      PriceTypeSupported = false;
      }

      protected override void OnBarUpdate()
      {
      DRising.Set(Close[0]);
      DNeutral.Set(Close[0]);
      DFalling.Set(Close[0]);
      KLine.Set(Close[0]);

      if (CurrentBar < 1)
      return;

      if (Rising(Stochastics(K, D, Smooth)))
      {
      DRisingPlot.Set(1, Stochastics(K, D, Smooth)[1]);
      DRisingPlot.Set(Stochastics(K, D, Smooth)[0]);
      }

      else if (Falling(Stochastics(K, D, Smooth)))
      {
      DFallingPlot.Set(1, Stochastics(K, D, Smooth)[1]);
      DFallingPlot.Set(Stochastics(K, D, Smooth)[0]);
      }

      else
      {
      DNeutralPlot.Set(1, Stochastics(K, D, Smooth)[1]);
      DNeutralPlot.Set(Stochastics(K, D, Smooth)[0]);
      }


      }
      This is all over the place but I'm learning till I get this, any pointers much appreciated,

      Thanks,
      Jeremy

      Comment


        #4
        Did you add the plots into the Properties? Check out the Properties section in the reference sample. You will need those.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh, I entered the plots into the Indicator wizard, but apart from that the only "Properties" section I can find is the large "Properties" section at the very bottom of the code which is by default hidden from the user. As I understand it the samples make no reference to editing this area directly. My misunderstanding, thanks for your patience,

          Jeremy

          Comment


            #6
            You will need to expand that big Properties section. If you don't mind you could post up the current rendition of your code. After I see what you have right now I can provide you with some pointers to get you going. Cheers.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hi Josh,

              Thanks for the help, good news is I've finally managed to make a smoothed StochRSI and plot it in color. Before I was looking at the entire indicator code, but then discovered the [+] buttons at the side of the code to popup the Properties section only, so I've made some progress.

              Only thing now is in my color version the smooth line is not plotted, it's the StochRSI line that is both plotted and colored.

              I'd like the smooth line to be plotted and colored, and StochRSI line plotted only.

              Here's my code:

              namespace NinjaTrader.Indicator
              {
              [Description("Sample SMA plotted with three colors.")]
              [Gui.Design.DisplayName("StochRSI_SmoothedColor")]
              public class StochRSI_SmoothedColor : Indicator
              {
              #region Variables
              private int period = 14;
              private int smooth = 4;
              #endregion

              protected override void Initialize()
              {
              Add(new Plot(Color.Green, "StochRSI"));
              Add(new Plot(Color.LimeGreen, PlotStyle.Line, "Rising"));
              Add(new Plot(Color.Red, PlotStyle.Line, "Falling"));
              Add(new Plot(Color.Yellow, PlotStyle.Line, "Neutral"));

              CalculateOnBarClose = true;
              Overlay = false;
              }

              protected override void OnBarUpdate()
              {
              if (CurrentBar < 1)
              return;

              if (Rising(StochRSI_Smoothed(Period, Smooth)))
              {
              RisingPlot.Set(1, StochRSI_Smoothed(Period, Smooth)[1]);

              RisingPlot.Set(StochRSI_Smoothed(Period, Smooth)[0]);
              }

              else if (Falling(StochRSI_Smoothed(Period, Smooth)))
              {
              FallingPlot.Set(1, StochRSI_Smoothed(Period, Smooth)[1]);

              FallingPlot.Set(StochRSI_Smoothed(Period, Smooth)[0]);
              }

              else
              {
              NeutralPlot.Set(1, StochRSI_Smoothed(Period, Smooth)[1]);

              NeutralPlot.Set(StochRSI_Smoothed(Period, Smooth)[0]);
              }
              }

              #region Properties

              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries RisingPlot
              {
              get { return Values[1]; }
              }

              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries FallingPlot
              {
              get { return Values[2]; }
              }

              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries NeutralPlot
              {
              get { return Values[3]; }
              }

              [Description("Numbers of bars used for calculations")]
              [Category("Parameters")]
              public int Period
              {
              get { return period; }
              set { period = Math.Max(1, value); }
              }

              [Description("Smoothing period for SMA")]
              [Category("Parameters")]
              public int Smooth
              {
              get { return smooth; }
              set { smooth = Math.Max(1, value); }
              }
              #endregion
              }
              }
              Many thanks for your help and Happy New Year ,

              Kind Regards,
              Jeremy

              Comment


                #8
                Hi jeremymgp,

                I am unfamiliar with the implementation of StochRSI since it is probably a custom indicator you have.

                When you do the .Set stuff you want it done on the plot you want. So for instance (I am just guessing what it is for your indicator), if you wanted to plot the smooth line you might do something like this:
                Code:
                RisingPlot.Set(StochRSI_Smoothed(Period, Smooth)[COLOR=Red].Smooth[/COLOR][0])
                I am assuming to access the smooth line you use .Smooth for your indicator.
                Now to just simply plot StochR_Smoothed you need to add another Values set in the Properties.
                Code:
                [Browsable(false)] 
                [XmlIgnore()]
                public DataSeries StochRSmooth
                {
                    get { return Values[[COLOR=Red]0[/COLOR]]; }
                }
                Then now in your OnBarUpdate() you want to do:
                Code:
                StochRSmooth.Set(StochRSI_Smoothed(Period, Smooth)[0]);
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Yippee, looks like I've done it. Only weird thing is when I save the indicator, copy it into a zip file, then try to import the zipped indicator, I can't get the indicator to show in the:
                  Control Center > Tools > Edit NinjaScript > Indicator box.

                  However if I right click a chart and click Indicators, I can select the indicator fine.

                  Just don't want to distribute this if the zip file isn't 100% OK.

                  Thanks,
                  Jeremy

                  Comment


                    #10
                    To distribute...

                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      Hello everyone,

                      Please find attached a color Stochastics indicator, it seems several people have shown interest in this and it also serves as a handy template for anyone wanting to color code indicators with more than one plot.

                      A huge thanks to Ray and Josh for their prompt and accurate response to my questions, hope this helps and good luck trading everyone,

                      Kind Regards,
                      Jeremy
                      Attached Files

                      Comment


                        #12
                        Thanks for the contribution jeremymgp. We appreciate it.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by tsantospinto, 04-12-2024, 07:04 PM
                        5 responses
                        67 views
                        0 likes
                        Last Post tsantospinto  
                        Started by cre8able, Today, 03:20 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post cre8able  
                        Started by Fran888, 02-16-2024, 10:48 AM
                        3 responses
                        49 views
                        0 likes
                        Last Post Sam2515
                        by Sam2515
                         
                        Started by martin70, 03-24-2023, 04:58 AM
                        15 responses
                        115 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by The_Sec, Today, 02:29 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X