Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing MAEnvelope indicator

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

    Referencing MAEnvelope indicator

    I am trying to code an indicator that will draw a dot on the screen below a candle when the lowerband of the MAEnvelope crosses above the EMA line.

    This is my code:

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1)
    return;

    if (CrossAbove(MAEnvelope(0.5,25).LowerBand, EMA(145), 1))
    DrawDot(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
    }


    But it does not work. Am I referencing the MAEnvelope lowerband correctly?

    #2
    What your code says is when the lowerband crosses above the EMA, draw a dot. Is that what you are after? I suggest you print values of both the MAEnvelope and your EMA to see what they are evaluated as. Then you can run comparisons by hand and know what your code is doing.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Yes that is correct. I would like the dot to plot when the lowerband crosses above the ema.

      Comment


        #4
        I suggest you add Print()s so you can see what those values are evaluated as. Only then will you be able to find areas where the dot should have occurred.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I tried adding the following line

          Print((MAEnvelope(0.5,25).LowerBand[0]));

          But it did not send anything to the output window.

          Comment


            #6
            Please check your Control Center logs for errors.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Interesting, I forgot to look there too for errors.

              I get the following error

              Error on calling the 'OnBarUpdate' method for indicator 'AA_USTLong' on bar 1: Unable to cast object of type 'NinjaTrader.Indicator.DataSeriesHelper' to type 'NinjaTrader.Data.Bars'.

              Will

              Comment


                #8
                You will need to debug this to find which line is in question here. Please use try-catch blocks to try and isolate this. http://www.ninjatrader-support2.com/...ead.php?t=9825
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

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