Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

rising/falling source code?

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

    #16
    WohooOOOoooo THANK YOU SO MUCH!! that saves me a lot of frustrating hours in front of the screen not knowing were to go or how to , haha, thanks!

    Comment


      #17
      kabbot,

      No problem.

      Please don't hesitate to contact us should you require additional assistance.
      Adam P.NinjaTrader Customer Service

      Comment


        #18
        me again, im having a couple compiling errors that say
        "The operator "<" cant be applied to operators type "double" and "Ninjatrader.Data.DataSeries"

        what did i broke? lol

        instead of making a whole new indi i just wanna plot some text on the price panel:

        if( Close[0] >=MiddleTop);

        {DrawTextFixed("Trend", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}

        Comment


          #19
          kabott,

          For one, you don't want to close an if statement like this :

          if( Close[0] >=MiddleTop);

          You will need to remove the ;

          Secondly, I am not sure if anything is wrong with that condition unless MiddleTop is a dataseries. Even then you are reporting an error with a different logical operator "<".

          Perhaps that particular error is coming from elsewhere?
          Adam P.NinjaTrader Customer Service

          Comment


            #20
            If "MiddleTop" is defined as a DataSeries, then you will need MiddleTop[0].
            A "DataSeries" can be referred to as it's name, as in, Close etc when a DataSeries is called for, but the indexing "[X]" is what converts it to a double value.

            VT

            Comment


              #21
              Originally posted by kabott View Post
              me again, im having a couple compiling errors that say
              "The operator "<" cant be applied to operators type "double" and "Ninjatrader.Data.DataSeries"

              what did i broke? lol

              instead of making a whole new indi i just wanna plot some text on the price panel:

              if( Close[0] >=MiddleTop);

              {DrawTextFixed("Trend", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}
              It looks then like MiddleTop is a Plot or DataSeries. In that case, you need to write that as:

              if( Close[0] >=MiddleTop[0])

              Comment


                #22
                dang , this is so frustrating , the script file that's gaving the error is the same im working on, so it has to be here, how do i solve the Data series issue?


                namespace NinjaTrader.Indicator
                {
                /// <summary>
                /// Moving Average Envelopes
                /// </summary>
                [Description("Plots % envelopes around a moving average")]
                public class MAEnvelopesColorFill : Indicator
                {
                #region Variables
                private int matype = 3;
                private int period = 14;
                private double envelopePercentage = 1.5;
                private Color fillColorUpper= Color.Gray;
                private Color fillColorLower= Color.Red;

                private Color maUp = Color.Green;
                private Color maDown = Color.Red;

                private int opacity = 2;
                #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()
                {
                // Adds a plot for the MA values to be stored in
                Add(new Plot(Color.Blue, "Upper"));
                Add(new Plot(new Pen(Color.Black, 2), PlotStyle.Line, "Middle"));
                Add(new Plot(Color.Black, "Lower"));
                Add(new Plot(Color.Black, "MiddleTop"));
                Add(new Plot(Color.Black, "MiddleBottom"));


                Plots[1].Pen.DashStyle = DashStyle.Dash;

                Overlay = true;
                }

                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
                double maValue = 0;

                switch (matype)
                {
                case 1:
                {
                Middle.Set(maValue = EMA(Inputs[0], Period)[0]);
                break;
                }
                case 2:
                {
                Middle.Set(maValue = HMA(Inputs[0], Period)[0]);
                break;
                }
                case 3:
                {
                Middle.Set(maValue = SMA(Inputs[0], Period)[0]);
                break;
                }
                case 4:
                {
                Middle.Set(maValue = TMA(Inputs[0], Period)[0]);
                break;
                }
                case 5:
                {
                Middle.Set(maValue = TEMA(Inputs[0], Period)[0]);
                break;
                }
                case 6:
                {
                Middle.Set(maValue = WMA(Inputs[0], Period)[0]);
                break;
                }


                }


                Upper.Set(maValue + (maValue * EnvelopePercentage / 100));
                Lower.Set(maValue - (maValue * EnvelopePercentage / 100));
                MiddleTop.Set( maValue - (maValue * EnvelopePercentage / 200));
                MiddleBottom.Set(maValue + (maValue * EnvelopePercentage / 200));

                IRegion region = DrawRegion("tag1", CurrentBar, 0, Upper, Middle, Color.Empty, fillColorUpper, Opacity);
                IRegion region2 = DrawRegion("tag2", CurrentBar, 0, Middle, Lower, Color.Empty, fillColorLower, Opacity);

                {
                if (Rising(Middle))
                { PlotColors[1][0]= maUp; }
                else
                { PlotColors[1][0]= maDown; }
                }

                {


                DrawOnPricePanel= true;
                if( Close[0] >=MiddleTop)

                {DrawTextFixed("Trend", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}

                if(Close[0] >= Middle && Close[0] <MiddleTop)

                {DrawTextFixed("Trend", " A - Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Maroon, Color.Maroon, 7);}

                if( Close[0] <= Middle && Close[0] >MiddleBottom)

                {DrawTextFixed("Trend", " A - Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.DarkGreen, Color.DarkGreen, 7);}

                if( Close[0] < Middle && Close[0] >MiddleBottom)

                {DrawTextFixed("Trend", " Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Green, Color.Green, 7);}

                Comment


                  #23
                  As Koganam and VTtrader pointed out,

                  You are comparing against dataseries.

                  You need to change things like : MiddleTop to MiddleTop[0]

                  If ( Close[0] > MiddleTop )

                  Is comparing a double against a dataseries, without telling it which element of the dataseries you want to compare against. DataSeries' are collections of values, not a single value itself.

                  Here is some more information : http://www.ninjatrader.com/support/h...ries_class.htm

                  -Adam Profitt
                  Last edited by NinjaTrader_AdamP; 11-28-2011, 04:22 PM.
                  Adam P.NinjaTrader Customer Service

                  Comment


                    #24
                    Originally posted by koganam View Post
                    It looks then like MiddleTop is a Plot or DataSeries. In that case, you need to write that as:

                    if( Close[0] >=MiddleTop[0])

                    Ok ill try that

                    Comment


                      #25
                      ok, now it gets stuck in "Overbought" right from the beginning and doesn't change no more, it also makes an other channel with the same modification that works get stuck too

                      {

                      if( Close[0] >=MiddleTop[0])
                      {DrawTextFixed("TOverbought", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}
                      else
                      {RemoveDrawObject("TOverbought");}

                      if(Close[0] >= Middle[0] && Close[0] <MiddleTop[0])
                      {DrawTextFixed("TAOverbought", " A - Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Maroon, Color.Maroon, 7);}
                      else
                      {RemoveDrawObject("TAOverbought");}

                      if( Close[0] <= Middle[0] && Close[0] >MiddleBottom[0])
                      {DrawTextFixed("TAOversold", " A - Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.DarkGreen, Color.DarkGreen, 7);}
                      else
                      {RemoveDrawObject("TAOversold");}

                      if( Close[0] < Middle[0] && Close[0] >MiddleBottom[0])
                      {DrawTextFixed("TOversold", " Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Green, Color.Green, 7);}
                      else
                      {RemoveDrawObject("TOversold");}

                      }

                      Comment


                        #26
                        kabott, we unfortunately could not debug this custom code for you here - best approach is simplying the script as much as possible and then printing variable / value info to the output window to better understand the sequence of events leading to the unexpected outcome you see.

                        Here's a tip on how to effectively use Print statements :

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        648 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 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
                        575 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X