Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

is EMA+/-(2*ATR) indicator on indicator?

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

    #16
    i seem to get the same ERROR. and nothing new on the LOG.

    Comment


      #17
      Originally posted by JimPunkrockford View Post
      i seem to get the same ERROR. and nothing new on the LOG.
      Please cut and paste your entire OnBarUpdate() event handler in here. Not a picture; text please.

      Comment


        #18
        protected override void OnBarUpdate()
        {
        if (CurrentBar < 1) return;
        // Use this method for calculating your indicator values. Assign a value to each
        // plot below by replacing 'Close[0]' with your own formula.
        PlotHi.Set("My line2" + CurrentBar, 1, EMA(EMAperiod)[1] + (ATR(ATRperiod)[1]) * (1 + 1),
        0, EMA(EMAperiod)[0] + (ATR(ATRperiod)[0]) * (1 + 1), Color.Red);

        //PlotLo.Set(Close[0]);
        }

        Comment


          #19
          Originally posted by JimPunkrockford View Post
          protected override void OnBarUpdate()
          {
          if (CurrentBar < 1) return;
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          PlotHi.Set("My line2" + CurrentBar, 1, EMA(EMAperiod)[1] + (ATR(ATRperiod)[1]) * (1 + 1),
          0, EMA(EMAperiod)[0] + (ATR(ATRperiod)[0]) * (1 + 1), Color.Red);

          //PlotLo.Set(Close[0]);
          }
          That is again because you are trying to set a Plot() to something other than a double. (Emphasis mine). If you want to draw a line, you should be saying so.
          Code:
          DrawLine("My line2" + CurrentBar, 1, EMA(EMAperiod)[1] + (ATR(ATRperiod)[1]) * (1 + 1), 
                                                          0, EMA(EMAperiod)[0] + (ATR(ATRperiod)[0]) * (1 + 1), Color.Red);

          Comment


            #20
            ok then, now we're cooking with gas. that was originally what i had minus your current bar< 1. so that was really the key piece of code.

            the only thing that i would like is if i could use the colors from Plot0 and Plot1. i identified them as lines, red and green respectively, and they show up as user defined options when loading the indicator. but because i stipulate "Color.Red" and "Color.Green" in my event handler, i am unable to change them around while loading the indicator. is there some way to change "Color.Red" so instead it is the color of Plot0?



            protected override void Initialize()
            {
            Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Plot0"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot1"));
            Overlay = true;
            }

            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
            if (CurrentBar < 1) return;
            DrawLine("My line2" + CurrentBar, 1, EMA(eMAPeriod)[1] + (ATR(aTRPeriod)[1]) * (1 * offsetMultiplier),
            0, EMA(eMAPeriod)[0] + (ATR(aTRPeriod)[0]) * (1 * offsetMultiplier), Color.Red);

            DrawLine("My line" + CurrentBar, 1, EMA(eMAPeriod)[1] + (ATR(aTRPeriod)[1]) * (-1 * offsetMultiplier),
            0, EMA(eMAPeriod)[0] + (ATR(aTRPeriod)[0]) * (-1 * offsetMultiplier), Color.Green);

            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            //Plot0.Set(Close[0]);
            //Plot1.Set(Close[0]);
            }

            Comment


              #21
              Hello JimPunkrockford,

              Plot0 will have the same color as you set (Color.Red) and these should be linked.

              If you're having issues changing the color, it may because you have not removed/re-added the indicator to your chart.

              Anything in the Initialize() method will only be called once the indicator is added. This means if you changed Color.Red to Color.DarkRed, you wouldn't see this change until you reapplied the indicator to your chart.
              MatthewNinjaTrader Product Management

              Comment


                #22
                hmm, i don't think so. no matter what i do the lines are always red and green. i remove the indicator hit "ok" then reload, change colors hit "ok" and still same colors.

                Comment


                  #23
                  Jim, can you please give this variation here a try -

                  if (CurrentBar < 1) return;
                  DrawLine("My line2" + CurrentBar, 1, EMA(eMAPeriod)[1] + (ATR(aTRPeriod)[1]) * (1 * offsetMultiplier),
                  0, EMA(eMAPeriod)[0] + (ATR(aTRPeriod)[0]) * (1 * offsetMultiplier), Plots[0].Pen.Color);

                  DrawLine("My line" + CurrentBar, 1, EMA(eMAPeriod)[1] + (ATR(aTRPeriod)[1]) * (-1 * offsetMultiplier),
                  0, EMA(eMAPeriod)[0] + (ATR(aTRPeriod)[0]) * (-1 * offsetMultiplier), Plots[1].Pen.Color);

                  Comment


                    #24
                    ahh yes, the colors can now be set. unfortunately that is all, i can't change line widths or make dashed or change to dots.

                    would that be an easy fix? if not, no worries

                    Comment


                      #25
                      Great on the colors, you can switch to using another DrawLine overload that includes the width / dashstyle parameter, please see - http://www.ninjatrader.com/support/h...7/drawline.htm

                      Comment


                        #26
                        Originally posted by JimPunkrockford View Post
                        ahh yes, the colors can now be set. unfortunately that is all, i can't change line widths or make dashed or change to dots.

                        would that be an easy fix? if not, no worries
                        If your Plot()s are never being set, what is the purpose of having the objects at all? Just using them as a repository of color seems rather a waste, as making the line colors a parameter just makes a little more sense.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        580 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        336 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
                        554 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        552 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X