Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 sidlercom80, 10-28-2023, 08:49 AM
                170 responses
                2,273 views
                0 likes
                Last Post sidlercom80  
                Started by Irukandji, Yesterday, 02:53 AM
                2 responses
                17 views
                0 likes
                Last Post Irukandji  
                Started by adeelshahzad, Today, 03:54 AM
                0 responses
                3 views
                0 likes
                Last Post adeelshahzad  
                Started by CortexZenUSA, Today, 12:53 AM
                0 responses
                3 views
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Working...
                X